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
Unexpected result tzDiff #23
Comments
"Maybe". All time zone libraries have odd corner cases, it seems. I chases a special case for London for a long time in my [anytime[(https://github.com/eddelbuettel/anytime) package (which uses the corresponding Boost library). In general, I think you want Here it is with library(RcppCCTZ)
fromtz <- "UTC" #Europe/London"
totz <- "Europe/Berlin"
dt <- as.Date("2010-01-01")
tzDiff(fromtz, totz, dt, verbose=TRUE)
dt <- as.Date("2017-07-01") # try DST
tzDiff(fromtz, totz, dt, verbose=TRUE) |
Also: your call was wrong in the sense that dt <- as.POSIXct("2010-01-01")
# ...
dt <- as.POSIXct("2017-07-01") # try DST in which case you get 1 and 2 hours (to UTC) which, as I recall, are the correct answers. |
My bad. With a POSIXct date all works as expected. |
I should test and/or convert though. |
I could give it a shot. I also think vectorizing over the dt argument would be useful |
Reopening to further discuss whether or not Dates should be supported As I see it there are basically three options:
As mentioned in #24 , from a practical standpoint I think it makes sense to allow Dates. And between options 1. and 2. , either would work for me. 1. is perhaps more what R does (eg. |
My main problem is R> as.POSIXct(Sys.Date())
[1] "2017-11-23 18:00:00 CST"
R> which makes of course total sense once you think it through:
but this is still far from useful. |
You have convinced me, making it accept dates requires too many assumptions to be made. I could modify #24 to only have it accept |
I was about to suggest that to. Go ahead and pile another commit (or two, if you need them) onto the PR. It looked good so far. |
PR Updated |
(Thanks. It's good form to keep it open and then add |
Hi,
Using tzDiff with one of the timezones set to "Europe/London" gives unexpected results. Here is an example:
The last line returns 0, where a 1 hour difference would be expected.
verbose=TRUE
seems to indicate the "Europe/London" date gets parsed as a +0100 timezone-offset instead of +0000.As a comparison, both the following lines return a 1h difference:
The text was updated successfully, but these errors were encountered: