tidyverse / lubridate

Make working with dates in R just that little bit easier
https://lubridate.tidyverse.org
GNU General Public License v3.0
724 stars 207 forks source link

tests failing #1139

Open nunotexbsd opened 10 months ago

nunotexbsd commented 10 months ago

FreeBSD 13.2 /R 4.3.1

R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: amd64-portbld-freebsd13.2 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(testthat)
> library(lubridate)
Warning: Your system is mis-configured: '/var/db/timezone/localtime' is not a symlink
Warning: '/var/db/timezone/localtime' is not identical to any known timezone file

Attaching package: 'lubridate'

The following objects are masked from 'package:base':

    date, intersect, setdiff, union

>
> test_check("lubridate")
[ FAIL 5 | WARN 3 | SKIP 11 | PASS 3027 ]

== Skipped tests (11) ==========================================================
* FIXME: activate when timechange#29 isfixed (1): 'test-periods.R:650:3'
* FIXME: time_length should be same on sides of DST? (1):
  'test-timespans.R:55:3'
* FIXME: ymd_hms OSz parsing (2): 'test-parsers.R:263:3',
  'test-parsers.R:278:3'
* On CRAN (7): 'test-namespace.R:33:3', 'test-namespace.R:44:3',
  'test-ops-integer-division.R:17:3', 'test-parsers.R:1122:3',
  'test-parsers.R:1141:3', 'test-pretty.R:4:3', 'test-vctrs.R:549:3'

== Failed tests ================================================================
-- Error ('test-Dates.R:15:3'): as_date works ----------------------------------
Error in `as.POSIXlt.character(x, tz, ...)`: character string is not in a standard unambiguous format
Backtrace:
    x
 1. +-base::as.POSIXct("2010-08-03 00:59:59.23") at test-Dates.R:15:2
 2. \-base::as.POSIXct.default("2010-08-03 00:59:59.23")
 3.   +-base::as.POSIXct(as.POSIXlt(x, tz, ...), tz, ...)
 4.   +-base::as.POSIXlt(x, tz, ...)
 5.   \-base::as.POSIXlt.character(x, tz, ...)
-- Failure ('test-accessors.R:480:3'): date accessor extracts correct date -----
date(posct) (`actual`) not equal to as.Date("2010-02-03") (`expected`).

`actual`:   NA
`expected`: "2010-02-03"
-- Error ('test-format_ISO8601.R:35:3'): Formatting a datetime works -----------
Error in `h(simpleError(msg, call))`: error in evaluating the argument 'x' in selecting a method for function 'format_ISO8601': character string is not in a standard unambiguous format
Backtrace:
     x
  1. +-testthat::expect_equal(...) at test-format_ISO8601.R:35:2
  2. | \-testthat::quasi_label(enquo(object), label, arg = "object")
  3. |   \-rlang::eval_bare(expr, quo_get_env(quo))
  4. +-lubridate::format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"))
  5. +-base::as.POSIXct("2018-02-01 03:04:05", tz = "EST")
  6. +-base::as.POSIXct.default("2018-02-01 03:04:05", tz = "EST")
  7. | +-base::as.POSIXct(as.POSIXlt(x, tz, ...), tz, ...)
  8. | +-base::as.POSIXlt(x, tz, ...)
  9. | \-base::as.POSIXlt.character(x, tz, ...)
 10. |   \-base::stop("character string is not in a standard unambiguous format")
 11. \-base::.handleSimpleError(...)
 12.   \-base (local) h(simpleError(msg, call))
-- Error ('test-intervals.R:803:3'): %% on interval uses m+ arithmetic ---------
Error in `as.POSIXlt.character(x, tz, ...)`: character string is not in a standard unambiguous format
Backtrace:
    x
 1. +-base::as.POSIXct(start) at test-intervals.R:803:2
 2. \-base::as.POSIXct.default(start)
 3.   +-base::as.POSIXct(as.POSIXlt(x, tz, ...), tz, ...)
 4.   +-base::as.POSIXlt(x, tz, ...)
 5.   \-base::as.POSIXlt.character(x, tz, ...)
-- Error ('test-ops-compare.R:2:3'): Comparison operators work with POSIX and Date objects --
Error in `as.POSIXlt.character(x, tz, ...)`: character string is not in a standard unambiguous format
Backtrace:
    x
 1. +-testthat::expect_true(...) at test-ops-compare.R:2:2
 2. | \-testthat::quasi_label(enquo(object), label, arg = "object")
 3. |   \-rlang::eval_bare(expr, quo_get_env(quo))
 4. \-lubridate (local) `==.POSIXt`(ymd_hms("2016-01-03 00:00:00", tz = ""), "2016-01-03 00:00:00")
 5.   +-base::as.POSIXct(e2)
 6.   \-base::as.POSIXct.default(e2)
 7.     +-base::as.POSIXct(as.POSIXlt(x, tz, ...), tz, ...)
 8.     +-base::as.POSIXlt(x, tz, ...)
 9.     \-base::as.POSIXlt.character(x, tz, ...)

[ FAIL 5 | WARN 3 | SKIP 11 | PASS 3027 ]
Error: Test failures
Execution halted

Any clues? Thanks

vspinu commented 10 months ago

No idea, was it working with the older version?

As the message suggests your tzone database might not be in the location as suggested. Our tzone db lookup is here Very simple code, you can see what's going on by yourself. If your problem is generic then a PR would be very much appreciated. Thanks!

vspinu commented 10 months ago

Our results are good on debian and fedora, so if indeed an issue it's FreeBSD specific.

nunotexbsd commented 10 months ago

@vspinu

It seems that some canonical TZs originates the error, EST in tests. Any clue about it? Maybe a R configuration that needs be fixed?

Attaching package: ‘lubridate’

The following objects are masked from ‘package:base’:

    date, intersect, setdiff, union

> format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"), usetz = TRUE)
Error in h(simpleError(msg, call)) :
  error in evaluating the argument 'x' in selecting a method for function 'format_ISO8601': character string is not in a standard unambiguous format

> format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "Europe/Lisbon"), usetz = TRUE)
[1] "2018-02-01T03:04:05+0000"

> format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "GMT"), usetz = TRUE)
[1] "2018-02-01T03:04:05+0000"

> format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "MET"), usetz = TRUE)
[1] "2018-02-01T03:04:05+0100"
vspinu commented 10 months ago

Sorry, I misread. This is R base error and not lubridate specific. Strange for sure. It's probably tzone database related but the error is confusing. It might be worth reporting this to R folks.

  6. +-base::as.POSIXct.default("2018-02-01 03:04:05", tz = "EST")
  7. | +-base::as.POSIXct(as.POSIXlt(x, tz, ...), tz, ...)
  8. | +-base::as.POSIXlt(x, tz, ...)
  9. | \-base::as.POSIXlt.character(x, tz, ...)
 10. |   \-base::stop("character string is not in a standard unambiguous format")
Jehops commented 10 months ago

I see this when calling Sys.timezone().

> Sys.timezone()
Warning: Your system is mis-configured: ‘/etc/localtime’ is not a symlink
Warning: It is strongly recommended to set envionment variable TZ to ‘America/Halifax’ (or equivalent)
[1] "America/Halifax"

On FreeBSD /etc/localtime isn't a symlink, but a copy of the timezone file under /usr/share/zoneinfo. When I back up /etc/localtime and create a symlink, there is no warning.

# mv localtime localtime.bak
# ln -s /usr/share/zoneinfo/America/Halifax .
# mv localtime localtime.bak
# ln -s /usr/share/zoneinfo/America/Halifax /etc/localtime
% R --quiet -e "Sys.timezone()"
> Sys.timezone()
[1] "America/Halifax"

@nunotexbsd, do you have /etc/localtime? If so, does it match an entry in the timezone database? You can check with something like find /usr/share/zoneinfo/ -type f -exec cmp -s {} /etc/localtime \; -print;.

nunotexbsd commented 9 months ago

@Jehops

Hello and sorry for delay!

I'm running in a poudriere jail and /etc/localtime was not exist. I did create a symlink and R shows:

> Sys.timezone()
[1] "Europe/Lisbon"

It doesn't solve the following command (called by test unit):

> library(lubridate)

> format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"), usetz = TRUE)
Error in h(simpleError(msg, call)) :
  error in evaluating the argument 'x' in selecting a method for function 'format_ISO8601':
character string is not in a standard unambiguous format

> format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "GMT"), usetz = TRUE)
[1] "2018-02-01T03:04:05+0000"

> format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "Europe/Lisbon"), usetz = TRUE)
[1] "2018-02-01T03:04:05+0000"

Something wrong with "EST" timezone and it doesn't seems related to system /etc/localtime.

Thanks