-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
'UTC' equality can be extended to other equivalent time zones #319
Milestone
Comments
Thanks for the suggestion! As I noted in the R bugzilla tracker, using 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 |
Looks great! I wonder why it's faster... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: