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

force_tz does not recognize GMT #1122

Closed Zhuk66 closed 1 year ago

Zhuk66 commented 1 year ago

Here is a short example:

library(lubridate) x <- ydm_hm("2013-25-07 4:00am") force_tz(x, "GMT") Error in C_force_tz(to_posixct(time), tz, roll_dst) : CCTZ: Unrecognized output timezone: "GMT" 7: (function () traceback(2))() 6: C_force_tz(to_posixct(time), tz, roll_dst) 5: from_posixct(C_force_tz(to_posixct(time), tz, roll_dst), time) 4: .force_tz(time, tz, tzout, roll_dst) 3: timechange::time_force_tz(time, tz = tzone, roll_dst = roll_dst) 2: force_tz.default(x, "GMT") 1: force_tz(x, "GMT")

The following calls to force_tz worked:

force_tz(x, "GMT+0") [1] "2013-07-25 04:00:00 GMT"

force_tz(x, "America/New_York") [1] "2013-07-25 04:00:00 EDT"

My session information:

sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux

Matrix products: default BLAS: /opt/revr/ropen/4.0.2/lib64/R/lib/libRblas.so LAPACK: /opt/revr/ropen/4.0.2/lib64/R/lib/libRlapack.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] lubridate_1.9.2 timechange_0.2.0 purrr_1.0.1
[4] dplyr_1.1.1 pryr_0.1.6 devtools_2.4.5
[7] usethis_2.1.6 RevoUtilsMath_11.0.0

loaded via a namespace (and not attached): [1] Rcpp_1.0.10 compiler_4.0.2 pillar_1.9.0
[4] later_1.3.0 urlchecker_1.0.1 prettyunits_1.1.1 [7] profvis_0.3.7 remotes_2.4.2 tools_4.0.2
[10] digest_0.6.31 pkgbuild_1.4.0 pkgload_1.3.2
[13] tibble_3.2.1 memoise_2.0.1 lifecycle_1.0.3
[16] pkgconfig_2.0.3 rlang_1.1.0 shiny_1.7.4
[19] cli_3.6.1 rstudioapi_0.14 fastmap_1.1.1
[22] stringr_1.5.0 generics_0.1.3 RevoUtils_11.0.2 [25] fs_1.6.1 vctrs_0.6.1 htmlwidgets_1.6.2 [28] tidyselect_1.2.0 glue_1.6.2 R6_2.5.1
[31] processx_3.8.0 fansi_1.0.4 sessioninfo_1.2.2 [34] callr_3.7.3 magrittr_2.0.3 ps_1.7.4
[37] promises_1.2.0.1 codetools_0.2-19 ellipsis_0.3.2
[40] htmltools_0.5.5 mime_0.12 xtable_1.8-4
[43] httpuv_1.6.3 utf8_1.2.3 stringi_1.7.12
[46] miniUI_0.1.1.1 cachem_1.0.7 crayon_1.5.2

Also:

Sys.getenv("TZDIR") [1] "/usr/share/zoneinfo/"

nviets commented 1 year ago

Same issue here.

vspinu commented 1 year ago

Any reason why you are not using UTC instead?

vspinu commented 1 year ago

Could you devtools::install_github("vspinu/timechange") and try again? I have implemented a fallback for systems which don't have GMT in zoneinfo.