Open DavisVaughan opened 4 years ago
It turns out that the OS-supplied binary does contain a POSIX-style time zone string at the end: EST5EDT,M3.2.0,M11.1.0
which the parser could identify and use to extend the transition table indefinitely. The lack of this support is a bug in tz.cpp. I'm currently not sure how much work it will take to incorporate this, nor the schedule for getting it done.
Another bug on macOS (-DUSE_OS_TZDB=1
) is that the OS does not supply leap second information, at least as of 10.14.6. I believe they will supply it in the future (if they don't already on 10.15).
The lack of leap second information means that utc_clock
(et al.) is unavailable.
I'm very tempted to ship my own copy of the tzdb with the R package and forcibly set -DUSE_OS_TZDB=0
to avoid all of this. That was my original plan until I noticed how fast things run with the os tzdb.
R packages try to be cross platform, so standardizing the package on a "blessed" (by me, not you) version of the tzdb might be a better route for me (I'd have to bundle my own tzdb for Windows anyways).
Any thoughts on that idea generally? When I push updates for the package I would update the tzdb (and probably update the date.h
and tz.h
files)
Also: I learned a ton from this SO answer of yours. Thanks for that!
I don't know enough about R packages to advise you much on this issue. Full optimizations on will help with the database lookup stuff. Also there are lower-level techniques within this lib for getting things faster still. This is usually a convenience/performance tradeoff.
I'm not sure if this impacts your decision, but this library has been voted into C++20, and so hopefully within about a year, the C++ vendors will be supplying this library. Though I am not aware of their schedules on this matter.
It turns out that the OS-supplied binary does contain a POSIX-style time zone string at the end:
EST5EDT,M3.2.0,M11.1.0
which the parser could identify and use to extend the transition table indefinitely. The lack of this support is a bug in tz.cpp. I'm currently not sure how much work it will take to incorporate this, nor the schedule for getting it done.
@HowardHinnant do you know if the usage of this rule to extend the DST transitions into the future is incorporated in the version in C++20+ stdlib? Or is that also missing there?
C++20 should get the right answer. Apple has yet to ship this part of C++20 in its macOS development tools.
First off, great library! Secondly, I'm an R developer attempting to expose some of this library to R users through an R package. In doing so, I generally test a wide range of dates, which is where I came across what I think it a bug.
I'm on MacOS 10.14.5 if that matters.
Take this somewhat far in the future date:
Say I want to force that to
"America/New_York"
with the same clock time. Ignoring any DST boundary problems, I can do something like:With
-DUSE_OS_TZDB=0
this prints:With
-DUSE_OS_TZDB=1
this prints:I believe the correct answer is the first one,
2196-10-06 11:39:41 EDT
. This aligns with another R package, lubridate, which internally uses CCTZ.I'm not an expert at C++, but I did a little digging and it mainly looks like in
load_sys_info()
ther.save
member isn't getting the right value.Since this date is so large, it is outside the range of transitions, so
r.end
is set tosys_seconds(sys_days(year::max()/max_day));
. But no special handling is done for the DST.Is there a way to handle this consistently? Thanks!