Skip to content
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

with_tz() warns about invalid timezones, but returns them correctly anyway #602

Closed
steffilazerte opened this issue Nov 2, 2017 · 9 comments

Comments

@steffilazerte
Copy link

This is a problem I've noticed on Windows only (not my Ubuntu machine). The warnings are also popping up in the AppVeyor tests (but not on Travis CI for Ubuntu and Mac).

I think it's only in lubridate v0.7.0 (related to c10c8cf) but I had problems trying to install v0.6.0 to double check.

with_tz() warns about invalid timezones, but returns them correctly anyway...

> Sys.time()
[1] "2017-11-02 00:17:10 AST"

> lubridate::with_tz(Sys.time(), "UTC")
[1] "2017-11-02 04:17:26"

> lubridate::with_tz(Sys.time(), "America/Vancouver")
[1] "2017-11-01 21:17:28 PDT"
Warning message:
In lubridate::with_tz(Sys.time(), "America/Vancouver") :
  Unrecognized time zone 'America/Vancouver'

> lubridate::with_tz(Sys.time(), "Etc/GMT+8")
[1] "2017-11-01 20:18:25 -08"
Warning message:
In lubridate::with_tz(Sys.time(), "Etc/GMT+8") :
  Unrecognized time zone 'Etc/GMT+8'

If I try a non-legitimate name I get a second warning message (and UTC):

> lubridate::with_tz(Sys.time(), "America/Van")
[1] "2017-11-02 04:41:31 GMT"
Warning messages:
1: In lubridate::with_tz(Sys.time(), "America/Van") :
  Unrecognized time zone 'America/Van'
2: In as.POSIXlt.POSIXct(x, tz) : unknown timezone "America/Van"

The first two are both legitimate timezones (i.e. they're in OlsonNames())

> OlsonNames()[OlsonNames() == "America/Vancouver"]
[1] "America/Vancouver"

> OlsonNames()[OlsonNames() == "Etc/GMT+8"]
[1] "Etc/GMT+8"

> OlsonNames()[OlsonNames() == "America/Van"]
character(0)
@vspinu
Copy link
Member

vspinu commented Nov 2, 2017

I don't see that on my windows machine. The internal check relies on same Olson database as OlsonNames but through the CCTZ lookup mechanism. Do you see this warning with all Timezones? "America/New_York", "Europe/Amsterdam"?

Could you please check if force_tz works as expected:

> lubridate::force_tz(Sys.time(), "America/Chicago")
[1] "2017-11-02 10:52:20 CDT"

If force_tz doesn't work, its probably some local installation problem.

@steffilazerte
Copy link
Author

Thanks for your speedy reply,

Both with_tz and force_tz have problems on my Windows machine and on AppVeyor (in a clean testing package). However, as.POSIXct works fine.

The output of the failed tests from AppVeyor is here (the as.POSIXct tests passed): testthat.Rout.fail.txt

Considering that this is a problem on AppVeyor and that as.POSIXct works, do you still think it's a local installation problem?

Output from my Windows machine:

with_tz() does the conversion correctly but warns

> lubridate::with_tz(Sys.time(), tzone = "America/New_York")
[1] "2017-11-02 12:38:43 EDT"
Warning message:
In lubridate::with_tz(Sys.time(), tzone = "America/New_York") :
  Unrecognized time zone 'America/New_York'

> lubridate::with_tz(Sys.time(), tzone = "Europe/Amsterdam")
[1] "2017-11-02 17:39:15 CET"
Warning message:
In lubridate::with_tz(Sys.time(), tzone = "Europe/Amsterdam") :
  Unrecognized time zone 'Europe/Amsterdam'

force_tz() errors

> lubridate::force_tz(Sys.time(), tzone = "UTC")
[1] "2017-11-02 16:46:06 UTC"

> lubridate::force_tz(Sys.time(), tzone = "America/New_York")
Error in C_force_tz(time, tz = tzone, roll) : 
  CCTZ: Unrecognized output timezone: "America/New_York"

> lubridate::force_tz(Sys.time(), tzone = "America/Vancouver")
Error in C_force_tz(time, tz = tzone, roll) : 
  CCTZ: Unrecognized output timezone: "America/Vancouver"

> lubridate::force_tz(Sys.time(), tzone = "Europe/Amsterdam")
Error in C_force_tz(time, tz = tzone, roll) : 
  CCTZ: Unrecognized output timezone: "Europe/Amsterdam"

as.POSIXct() works fine

> as.POSIXct("2017-09-09 00:00:00", tz = "UTC")
[1] "2017-09-09 UTC"

> as.POSIXct("2017-09-09 00:00:00", tz = "Europe/Amsterdam")
[1] "2017-09-09 CEST"

> as.POSIXct("2017-09-09 00:00:00", tz = "America/New_York")
[1] "2017-09-09 EDT"

@vspinu
Copy link
Member

vspinu commented Nov 2, 2017

Ok, thanks. It's the TZDIR env issue. Preparing a fix asap.

@steffilazerte
Copy link
Author

Great!

@vspinu
Copy link
Member

vspinu commented Nov 2, 2017

@steffilazerte Do you have the ability to test the dev version? I pushed a fix which works for me. I would be extremely grateful if you could check it asap. Lubridate was removed from CRAN because it failed on solaris, and I think it's the same issue.

@steffilazerte
Copy link
Author

I'll give it a shot, get back to you soon.

@steffilazerte
Copy link
Author

steffilazerte commented Nov 2, 2017

It works perfectly on my windows machine. To double check I uninstalled the dev version and reinstalled from cran and I got all the same errors. Switching back to the dev version was perfect again.

I couldn't test on AppVeyor (it had problems installing lubridate from the github site), but I can't see any reason why that wouldn't be fixed as well.

Let me know if you need any other tests! Thanks!

@vspinu
Copy link
Member

vspinu commented Nov 2, 2017

Ok. Great. Nevermind for AppVeyor. I cloned your testing package and it's fixed. Thanks a bunch for you instant input!

@vspinu vspinu closed this as completed Nov 2, 2017
@steffilazerte
Copy link
Author

Awesome, glad to hear it worked out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants