-
Notifications
You must be signed in to change notification settings - Fork 60
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
Use the exported clock API instead of localtime.c #322
Conversation
LGTM, thanks |
clock tooling doesn't treat month or day as 0-indexed. This does have the side effect of making `amPm` 1-indexed, but that isn't too bad
We can't throw cpp11 errors when in a parallel thread
This avoids passing `""` to `locate_zone()`. clock normally handles `""` for you, but it does so by calling back to `Sys.timezone()` from C++, which isn't allowed when running in parallel.
Okay @jimhester, I'm finished. If it looks good to you, I can merge the clock PR and update this one to only have a Remote on dev clock, then we can merge this. A few notes: I've tweaked I've removed all mentions of I've removed I've added a few tests regarding I've added a few tests making assumptions about ambiguous/nonexistent times explicit. For ambiguous times, we default to always choosing the earliest of the two times. For nonexistent times, we return |
yeah this looks good to me, thank you for working on it! I may not merge this until Monday, I want to hunt down why the windows tests are failing in the current vroom master and get the CI green before merging, but it shouldn't require any changes to what you have done. |
Sounds good! Just merged the clock PR and updated the Remote here, so it should be good to go for you on Monday |
FYI clock 0.2.0 is on CRAN so I have adjusted the required version and removed the Remote |
A port of tidyverse/vroom#322 to readr
* Use the clock package to convert date times A port of tidyverse/vroom#322 to readr * Add withr to suggests
Closes #273
Closes #321
Alternative to #321, paired with r-lib/clock#213
@jimhester what if I provided you a callable API from clock to use? This would get you:
zone_name_load()
to ensure that an R error (through cpp11) is thrown if a bad zone name is passed, rather than a runtime errortz.cpp
If you could assume that
tz_
was constant, you could also callzone_name_load()
once for the entire column, which would be a little faster, but I'm not sure you can make that assumption in vroom, given that a user might have different time zones in the same vector of date-time strings?Regarding performance, right now clock uses the text version of the IANA time zone database. The underlying date library can also use the binary version of the database, which is much faster, but it currently has a few bugs. Even with the text version, it seems a little faster than the localtime version in the limited test below. I'll eventually switch to the binary version, and vroom would automatically inherit the benefits of that. (You can switch to using the binary version by flipping this define to
1
on a Mac https://github.com/r-lib/clock/blob/700ba688513b2bfa15c5cc7dbb81272a52357b3f/src/Makevars#L34)Note: Still need to removeDonelocaltime.c/h
from this PR. We can also talk about how this handles nonexistent times (DST gaps) and ambiguous times (DST fallbacks).