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

one hour difference for "Europe/London" #86

Closed
earowang opened this issue Dec 8, 2018 · 11 comments
Closed

one hour difference for "Europe/London" #86

earowang opened this issue Dec 8, 2018 · 11 comments

Comments

@earowang
Copy link

earowang commented Dec 8, 2018

Hi Dirk,

I have run through all possible time zones specified here. There's always one hour difference for London, regardless of date-time inputs and OS. Other time zones work as expected.

test_timezone <- function(tz) {
  withr::local_envvar(c("TZ" = tz))
  x <- "2016-12-09 09:10"
  format(anytime::utctime(x, tz = "UTC"))
}
test_timezone("Europe/London")
#> [1] "2016-12-09 10:10:00"

Created on 2018-12-08 by the reprex package (v0.2.1)

@eddelbuettel
Copy link
Owner

Sure, but why a new ticket? Did you see #51 and also #36 and #59?

@earowang
Copy link
Author

earowang commented Dec 8, 2018

Oops, sorry for the duplicate.

@earowang earowang closed this as completed Dec 8, 2018
@eddelbuettel
Copy link
Owner

Well I wish it wasn't a dupe or even single bug in the sense that I wish that Boost did the right thing here but something seems vexed with London :-/ There has not been that much development upstream to that part of Boost so I am not sure this will ever get perfect. Which was part of the reason I added the R fallback. Not perfect, but I have not been able to come up with something better.

@earowang
Copy link
Author

earowang commented Dec 9, 2018

R's fedora likely sets system time zone to "Europe/London", that's why some unit tests failed. Now I skip these tests for London, rhub::check_on_fedora() works fine.

@eddelbuettel
Copy link
Owner

Good to know you have a workaround. I can't quite work out whether the bug simply is that UTC (which has no daylight savings) and Europe/London (which has) are confused here and a weird correction is in place -- as UTC is often substituted in when nothing else is set.

In any event, it is a known wart for anytime which farms this out to ... something that gets this setting wrong. But most importantly your package is no longer affected as you found a workaround. In case you think of a way in which I could or should document this better let me know. That side we can always improve.

@earowang
Copy link
Author

earowang commented Dec 9, 2018

Re ?Sys.time():

A time zone region may be known by several names: for example "Europe/London" is also known as GB, GB-Eire, Europe/Belfast, Europe/Guernsey, Europe/Isle_of_Man and Europe/Jersey.

Several alternatives of "Europe/London" have no problem.

tzvec <- c(
  "Europe/London",
  "GB",
  "GB-Eire",
  "Europe/Belfast",
  "Europe/Guernsey",
  "Europe/Isle_of_Man"
)
test_timezone <- function(tz) {
  withr::local_envvar(c("TZ" = tz))
  x <- "2016-12-09 09:10"
  format(anytime::utctime(x, tz = "UTC"))
}

for (i in seq_along(tzvec)) {
  print(callr::r(test_timezone, args = list(tz = tzvec[i])))
}
#> [1] "2016-12-09 10:10:00"
#> [1] "2016-12-09 09:10:00"
#> [1] "2016-12-09 09:10:00"
#> [1] "2016-12-09 09:10:00"
#> [1] "2016-12-09 09:10:00"
#> [1] "2016-12-09 09:10:00"

Created on 2018-12-09 by the reprex package (v0.2.1)
Since Australia/Melbourne also involves DST, but I haven't experienced the same issue as Europe/London. I'm not sure it's related to DST.

In addition to skipping tests, I've also added a warning if system time zone is set to Europe/London in the function, which users should be made aware of unexpected results.

I would also add a new section in the documentation regarding Europe/London, suggesting users could specify the time zone to other names using Sys.setenv(TZ = ?).

@eddelbuettel
Copy link
Owner

eddelbuettel commented Dec 9, 2018

Good stuff. But you based this on the R documentation and parameters. Whereas anytime is based on Boost code and parameterisations.

Edit: Disgregard that comment. I was commenting from my phone.

@eddelbuettel
Copy link
Owner

Several alternatives of "Europe/London" have no problem.

That had been my best line of defence too. Almost as if it is used as / confused with UTC.

@eddelbuettel
Copy link
Owner

eddelbuettel commented Dec 9, 2018

The pointer from ?Sys.time() is good. I just added that to the help page in this commit 375e77c (though I mistakenly attributed it to #84 instead of this #86 in the commit message).

@earowang
Copy link
Author

earowang commented Dec 9, 2018

My bad. It's ?Sys.timezone().

@eddelbuettel
Copy link
Owner

eddelbuettel commented Dec 9, 2018

Dang. I couldawouldashoulda have checked myself. Will fix.

Done: 36b627d

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