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
I just filed this at data.table: Rdatatable/data.table#4117
And this fix for base R: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17674
I notice also several usages of testing UTC value in xts:
UTC
xts
xts/R/tzone.R:106: if (!(tzone(x) %in% c("UTC","GMT"))) xts/R/endpoints.R:133: Sys.getenv("TZ") %in% c("", "GMT", "UTC"))
If you're amenable, I would file a PR to an equivalent is_utc internal utility & replace the above instances
is_utc
I also filed a similar issue for lubridate: tidyverse/lubridate#844
lubridate
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion! As I noted in the R bugzilla tracker, using switch() seems to be about as fast as checking for equality (e.g. tz == "UTC") and can cover all cases. What do you think of that solution?
switch()
tz == "UTC"
in_utc <- function(tz) { utc_tz <- c("UTC", "GMT", "Etc/UTC", "Etc/GMT", "GMT-0", "GMT+0", "GMT0") if (is.null(tz)) tz <- Sys.timezone() return(tz %in% utc_tz) } is_utc <- function(tz) { if (is.null(tz)) { tz <- Sys.timezone() } switch(tz, "UTC" = , "GMT" = , "Etc/UTC" = , "Etc/GMT" = , "GMT-0" = , "GMT+0" = , "GMT0" = TRUE, FALSE) } tzones <- replicate(100, OlsonNames()) system.time(for(tz in tzones) is_utc(tz)) # ~0.035 system.time(for(tz in tzones) in_utc(tz)) # ~0.113
Sorry, something went wrong.
Looks great! I wonder why it's faster...
a9e6573
No branches or pull requests
I just filed this at data.table: Rdatatable/data.table#4117
And this fix for base R: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17674
I notice also several usages of testing
UTC
value inxts
:If you're amenable, I would file a PR to an equivalent
is_utc
internal utility & replace the above instancesI also filed a similar issue for
lubridate
: tidyverse/lubridate#844The text was updated successfully, but these errors were encountered: