-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timezones not working since the update to R 4.0.3 #928
Comments
I don't see this with CRAN lubridate, on macOS: ❯ a <- "1 Sep 2020 1:00pm" #make a string date
❯ dmy_hm(a, tz="Africa/Blantyre") #this throws an error
[1] "2020-09-01 13:00:00 CAT"
❯ getRversion()
[1] ‘4.0.3’
❯ Sys.timezone()
[1] "Europe/London" EDIT: this was on Mojave, possibly only an issue on Catalina? |
I am on Catalina and also unable to repro. Here was the change in R 4.0.3:
So my guess here is that the error occurs under certain configurations where the MacOS TZ database is corrupted or missing? From the
@rachaelmburke What is the value of |
The problem appears to occur if the # Running on Mac OS X Catalina (10.15.5) under R 4.0.3 w/ timezone changes
Sys.getenv("TZDIR")
#> [1] ""
lubridate::dmy_hm("1 Sep 2020 1:00pm", tz="Africa/Blantyre")
#> [1] "2020-09-01 13:00:00 CAT"
# Now in a fresh R session:
Sys.setenv(TZDIR = "internal") # (also fails for "macOS")
lubridate::dmy_hm("1 Sep 2020 1:00pm", tz="Africa/Blantyre")
#> Error in C_force_tz(time, tz = tzone, roll): CCTZ: Unrecognized output timezone: "Africa/Blantyre" |
Note that cctz requires that the TZDIR by a path not a special value like |
This bit me as well. I went as far as reinstalling macOS and R on my machine thinking there was something at the OS level that was wrong with my machine since a colleague using Windows 10 couldn't duplicate and it didn't happen on my other Mac. But with fresh installs of Catalina and R 4.0.3 both, this keeps occurring. |
@adamhsparks Did you install R from CRAN or from HomeBrew? Can you try to set |
R was installed using the Homebrew cask version of R, not the Homebrew formulae. |
I'm seeing this issue to on R4.0.3. R4.0.2 on the same system doesn't have this issue. Note that if I run @jjallaire's reprex above I get an error but he doesn't on the same code. Also if I run Sys.getenv("TZDIR") after executing the lubridate statement you can see that the environment variable has been set to "macOS".
Setting TZDIR to internal doesn't seem to help either.
Full disclosure I am testing MacOS 11 on this system. Both 11.0.0 Beta 10 and 11.0.1 Beta 1 have this issue. @jjallaire I note you aren't on the latest Catalina which I think is 10.15.7. Perhaps something has changed in later macOS builds that causes things to break? R is installed from CRAN. Adding an explicity TZDIR = "" or TZDIR = "internal" to .Renviron results in the same output. This does not occur on Windows or Ubuntu 20.04. |
I also tried setting TZDIR = "" in my .Renviron. |
Another idea: can you try setting it as
in If it is still set to Sys.setenv("TZDIR" = "/Library/Frameworks/R.framework/Resources/share/zoneinfo/") |
@gaborcsardi Your suggestion to set TZDIR to "/Library/Frameworks/R.framework/Resources/share/zoneinfo/"
|
FWIW, I don't see this issue on Big Sur, fully updated according to the update manager, the R 4.0.3 installer from CRAN, and CRAN lubridate. |
Yes, confirming, setting Now, what's the best method to deal with this error in a package that uses lubridate if it occurs on another user's machine? |
I think this will be probably fixed in lubridate. Until then a workaround would be to wrap calls to lubridate, and in the wrapper set |
Thank you, @gaborcsardi! I suspected it would be fixed in lubridate. We're not in a hurry to publish the package. I think that I can just keep an eye out for that fix and require that version and if need be implement what you have suggested here. |
Not sure whether I am on crack or what, but I reinstalled 4.0.3 on Oct, 21 and afaict everything was working great then. Now that the winter timezone is upon us (in Just a thought. |
I tried it again in the office today on my Mac there that also has Catalina and R4.0.3. No worries. We don't do DST here in Qld, so no time change for me (at the beginning of October), but could still be related? |
I would think that it is related macOS updates, and some versions of the macOS timezone DB are buggy. Actually, not really buggy, they are just more recent than the ones on other macOS versions/updates, and R decides to use them and sets FWIW these are my versions on Mojave, these work fine with R:
(I don't really understand why the two versions are mixed here.) |
Interesting... On my broken setup I see this...
|
My (broken machine) matches @gsiemon's broken setup. ❯ ls -l /var/db/timezone/
total 0
lrwxr-xr-x 1 root wheel 35 Oct 31 22:02 icutz -> /var/db/timezone/tz/2020d.1.0/icutz
drwxr-xr-x 3 root wheel 96 Oct 31 21:26 tz
lrwxr-xr-x 1 root wheel 29 Oct 31 21:26 tz_latest -> /var/db/timezone/tz/2020d.1.0
lrwxr-xr-x 1 root wheel 38 Oct 31 22:02 zoneinfo -> /var/db/timezone/tz/2020d.1.0/zoneinfo |
Yeah, small sample, but it seems that if |
I've just been back to my Timemachine backup and the timezone versions updated from 2020a.1.0 to 2020d.1.0 on October 27. I didn't install any updates then so I'm guessing this was pushed from Apple's end. That seems to reconcile others saying that R4.0.3 was working fine and then it suddenly stopped working. Files with differences between the two versions:
Most of these just look like routine timezone updates. I'm happy to send through anything that piques your interest. Edit: I've just reread your post @gaborcsardi. That makes a lot of sense. Newer TZ data causes switch from internal to macOS TZ data and somehow everything breaks. |
Hi... so glad it's not just me! Sorry to disrupt a "issue" / patch thread with what's now a support question.... but is there any chance someone could explain to me a work around that I can use in the mean time until this get fixed I can't quite work out how to set or change anything in R.environ or .Rprofile to change TZDIR. I'm on Catalina 10.15.4 I'm a doctor turned stats / epidemiology person. Learning more all the time about how my computer actually works, but definitely a newbie here. And I have a lot of code for an ongoing project that now doesn't work so well! Thanks, Rachael |
usethis::edit_r_profile() will open it for you and let you edit the file. You just need to restart RStudio after saving
…Sent from my iPhone
On 2 Nov 2020, at 21:56, Rachael Burke ***@***.***> wrote:
Hi... so glad it's not just me!
Sorry to disrupt a "issue" / patch thread with what's now a support question.... but is there any chance someone could explain to me a work around that I can use in the mean time until this get fixed
I can't quite work out how to set or change anything in R.environ or .Rprofile to change TZDIR.
I'm a doctor turned stats / epidemiology person. Learning more all the time about how my computer actually works, but definitely a newbie here. And I have a lot of code for an ongoing project that now doesn't work so well!
Thanks,
Rachael
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Amazing - thank you @adamhsparks (and everyone else). Fixed for now! |
I don't see this as |
Would be also good to know where exactly those strange "internal" ans "MacOS" values are set and by whom. |
Hm, on macOS HighSierra: CCTZ: Invalid timezone of the input vector: "" since this morning. my "/Library/Frameworks/R.framework/" is empty ..... cannot find anywhere else... changing lubridate commands to as.Posix Rbase does not make a difference |
Perhaps as an additional datapoint, this bug is inconsistent across different timezones for me:
Some TZs work, while others don't, with no apparent pattern. session info``` > devtools::session_info() ─ Session info ────────────────────────────────────────────────────────────────── setting value version R version 4.0.3 (2020-10-10) os macOS Big Sur 10.16 system x86_64, darwin17.0 ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz Europe/Berlin date 2020-11-25 ─ Packages ────────────────────────────────────────────────────────────────────── [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library
|
Hi everyone, |
Since feedback was asked-for, I can report that the most recent commit (aab2e30) does not resolve the issue for me 'out-of-the-box'. And when I try the explicit Sys.setenv("TZDIR" = "/usr/local/Cellar/r/4.0.3_2/lib/R/share/zoneinfo/") Though I'm not sure how to easily detect that path a priori. |
@mmuurr what does |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This helped me. Just had this issue recently and I don't remember what changed in my system except i did update packages. Not sure if Lubridate was one of them but if I reset the R environment and first run Sys.timezone that seems to do the trick. |
Per NEWS bullet https://github.com/tidyverse/lubridate/blob/master/NEWS.md#version-1792, It seems that this issue is fixed now right ? As it is not closed, just want to confirm. |
Yes, it should be fixed in devel. Will try to release to CRAN next week. |
Oh ok, The NEWS item was for 1.7.9.2 so I thought it was already fixed in the CRAN version. So it isn't ? |
@vspinu I understood what you meant I think. This has been fully fixed in #936 after first try in 4c8428b it it seems but I don't think the commit for the PR (6c535c8) made the last CRAN release 1.7.9.2 - the date is after the published date on CRAN, and I don't see the change in I reverted back the change in distill to use CRAN lubridate and wait for the next version you said you will release soon hopefully. Thank you. |
Sorry. It was a messup with tagging on my side this time :/ I am preparing a CRAN release. |
Version 1.7.10 ============== ### NEW FEATURES * `fast_strptime()` and `parse_date_time2()` now accept multiple formats and apply them in turn ### BUG FIXES * [#926](tidyverse/lubridate#926) Fix incorrect division of intervals by months involving leap years * Fix incorrect skipping of digits during parsing of the `%z` format Version 1.7.9.2 =============== ### NEW FEATURES * [#914](tidyverse/lubridate#914) New `rollforward()` function * [#928](tidyverse/lubridate#928) On startup lubridate now resets TZDIR to a proper directory when it is set to non-dir values like "internal" or "macOS" (a change introduced in R4.0.2) * [#630](tidyverse/lubridate#630) New parsing functions `ym()` and `my()` ### BUG FIXES * [#930](tidyverse/lubridate#930) `as.period()` on intervals now returns valid Periods with double fields (not integers) Version 1.7.9 ============= ### NEW FEATURES * [#871](tidyverse/lubridate#893) Add `vctrs` support ### BUG FIXES * [#890](tidyverse/lubridate#890) Correctly compute year in `quarter(..., with_year = TRUE)` * [#893](tidyverse/lubridate#893) Fix incorrect parsing of abbreviated months in locales with trailing dot (regression in v1.7.8) * [#886](tidyverse/lubridate#886) Fix `with_tz()` for POSIXlt objects * [#887](tidyverse/lubridate#887) Error on invalid numeric input to `month()` * [#889](tidyverse/lubridate#889) Export new dmonth function Version 1.7.8 ============= ### NEW FEATURES * (breaking) Year and month durations now assume 365.25 days in a year consistently in conversion and constructors. Particularly `dyears(1) == years(1)` is now `TRUE`. * Format and print methods for 0-length objects are more consistent. * New duration constructor `dmonths()` to complement other duration constructors. * * `duration()` constructor now accepts `months` and `years` arguments. * [#629](tidyverse/lubridate#629) Added `format_ISO8601()` methods. * [#672](tidyverse/lubridate#672) Eliminate all partial argument matches * [#674](tidyverse/lubridate#674) `as_date()` now ignores the `tz` argument * [#675](tidyverse/lubridate#675) `force_tz()`, `with_tz()`, `tz<-` convert dates to date-times * [#681](tidyverse/lubridate#681) New constants `NA_Date_` and `NA_POSIXct_` which parallel built-in primitive constants. * [#681](tidyverse/lubridate#681) New constructors `Date()` and `POSIXct()` which parallel built-in primitive constructors. * [#695](tidyverse/lubridate#695) Durations can now be compared with numeric vectors. * [#707](tidyverse/lubridate#707) Constructors return 0-length inputs when called with no arguments * [#713](tidyverse/lubridate#713) (breaking) `as_datetime()` always returns a `POSIXct()` * [#717](tidyverse/lubridate#717) Common generics are now defined in `generics` dependency package. * [#719](tidyverse/lubridate#719) Negative Durations are now displayed with leading `-`. * [#829](tidyverse/lubridate#829) `%within%` throws more meaningful messages when applied on unsupported classes * [#831](tidyverse/lubridate#831) Changing hour, minute or second of Date object now yields POSIXct. * [#869](tidyverse/lubridate#869) Propagate NAs to all internal components of a Period object ### BUG FIXES * [#682](tidyverse/lubridate#682) Fix quarter extraction with small `fiscal_start`s. * [#703](tidyverse/lubridate#703) `leap_year()` works with objects supported by `year()`. * [#778](tidyverse/lubridate#778) `duration()/period()/make_difftime()` work with repeated units * `c.Period` concatenation doesn't fail with empty components. * Honor `exact = TRUE` argument in `parse_date_time2`, which was so far ignored. Version 1.7.4 ============= ### NEW FEATURES * [#658](tidyverse/lubridate#658) `%within%` now accepts a list of intervals, in which case an instant is checked if it occurs within any of the supplied intervals. ### CHANGES * [#661](tidyverse/lubridate#661) Throw error on invalid multi-unit rounding. * [#633](tidyverse/lubridate#633) `%%` on intervals relies on `%m+` arithmetic and doesn't produce NAs when intermediate computations result in non-existent dates. * `tz()` always returns "UTC" when `tzone` attribute cannot be inferred. ### BUG FIXES * [#664](tidyverse/lubridate#664) Fix lookup of period functions in `as.period` * [#649](tidyverse/lubridate#664) Fix system timezone memoization Version 1.7.3 ============= ### BUG FIXES * [#643](tidyverse/lubridate#643), [#640](tidyverse/lubridate#640), [#645](tidyverse/lubridate#645) Fix faulty caching of system timezone.
Sorry to get back to this issue, but we are having this problem with our teams after upgrading to R 4.2.1 on Windows (coming from R 4.1.3, didn't have the warning): lubridate::now()
#> [1] "2022-09-15 14:17:10 CEST"
#> Warning message:
#> In with_tz(Sys.time(), tzone) : Unrecognized time zone ''
Sys.getlocale()
#> [1] "LC_COLLATE=Dutch_Netherlands.utf8;LC_CTYPE=Dutch_Netherlands.utf8;LC_MONETARY=Dutch_Netherlands.utf8;LC_NUMERIC=C;LC_TIME=Dutch_Netherlands.utf8"
Sys.timezone()
#> [1] "Europe/Berlin"
Sys.getenv("TZDIR")
#> [1] "C:/R/R/R-42~1.1/share/zoneinfo" Created on 2022-09-15 with reprex v2.0.2 Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.2.1 (2022-06-23 ucrt)
#> os Windows 10 x64 (build 19044)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Dutch_Netherlands.utf8
#> ctype Dutch_Netherlands.utf8
#> tz Europe/Berlin
#> date 2022-09-15
#> pandoc 2.18 @ C:/R/RStudio/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> cli 3.4.0 2022-09-08 [1] CRAN (R 4.1.3)
#> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.2)
#> evaluate 0.16 2022-08-09 [1] CRAN (R 4.1.3)
#> fansi 1.0.3 2022-03-24 [1] CRAN (R 4.1.3)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.0.4)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.2)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.1.3)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.3)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.0.5)
#> htmltools 0.5.3 2022-07-18 [1] CRAN (R 4.1.3)
#> knitr 1.40 2022-08-24 [1] CRAN (R 4.1.3)
#> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.0.5)
#> lubridate 1.8.0 2021-10-07 [1] CRAN (R 4.0.5)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.3)
#> pillar 1.8.1 2022-08-19 [1] CRAN (R 4.1.3)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.4)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.4)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.1.3)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.1.3)
#> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.1.3)
#> R.utils 2.12.0 2022-06-28 [1] CRAN (R 4.1.3)
#> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.1.3)
#> rlang 1.0.5 2022-08-31 [1] CRAN (R 4.1.3)
#> rmarkdown 2.16 2022-08-24 [1] CRAN (R 4.1.3)
#> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.1.3)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2)
#> stringi 1.7.8 2022-07-11 [1] CRAN (R 4.1.3)
#> stringr 1.4.1 2022-08-20 [1] CRAN (R 4.1.3)
#> styler 1.7.0 2022-03-13 [1] CRAN (R 4.1.3)
#> tibble 3.1.8 2022-07-22 [1] CRAN (R 4.1.3)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.0.5)
#> vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.1.3)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.3)
#> xfun 0.32 2022-08-10 [1] CRAN (R 4.1.3)
#> yaml 2.3.5 2022-02-21 [1] CRAN (R 4.1.2)
#>
#> [1] C:/R/RPakketten4
#> [2] C:/R/R/R-4.2.1/library
#>
#> ────────────────────────────────────────────────────────────────────────────── Perhaps the same as #945? |
@msberends given that the previous problem was over a year ago and on mac, it's probably different issue. I'd recommend creating a new issue instead. |
Makes sense, I'm sorry. Solution found - we had to reinstall |
I updated R yesterday to version 4.0.3 and now my timezone codes are throwing an error in lubridate.
For example
a <- "1 Sep 2020 1:00pm" #make a string date
This works fine:
But this doesn't work:
I get the error
For what it's worth, some of the three letter time zone abbreviations seem to work
But no other time zone specification works (have tried "Europe/London" and "Africa/Harare")
I've checked by system time zone
I'm not sure what's throwing the issue or if it is specific to lubridate, or something else (?)
The text was updated successfully, but these errors were encountered: