From 375e77cc8ad5f99c9c1950b9351bb1a9a1010a3c Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sun, 9 Dec 2018 08:19:35 -0600 Subject: [PATCH] small addition to help page for Europe/London issue #84 as well as at least three other (referenced) issues --- R/anytime.R | 14 ++++++++++++-- man/anytime.Rd | 12 +++++++++++- tests/gh_issue_84.R | 39 ++++++++++++++++++++++++++++++--------- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/R/anytime.R b/R/anytime.R index c5d68c9..6d9ef01 100644 --- a/R/anytime.R +++ b/R/anytime.R @@ -1,7 +1,7 @@ ## anytime: Use Boost Date_Time to convert date(time) data to POSIXt ## -## Copyright (C) 2015 - 2017 Dirk Eddelbuettel +## Copyright (C) 2015 - 2018 Dirk Eddelbuettel ## ## This file is part of anytime. ## @@ -71,7 +71,17 @@ ##' other hand, \code{c(Sys.Date(), NA)} works as expected parsing as ##' type Date with one missing value. See ##' \href{https://github.com/eddelbuettel/anytime/issues/11}{issue -##' ticket 11}) for more. +##' ticket 11} for more. +##' +##' Another known issue concerns conversion when the timezone is set +##' to \sQuote{Europe/London}, see GitHub issue tickets +##' \href{https://github.com/eddelbuettel/anytime/issues/36}{36}. +##' \href{https://github.com/eddelbuettel/anytime/issues/51}{51}. +##' \href{https://github.com/eddelbuettel/anytime/issues/59}{59}. and +##' \href{https://github.com/eddelbuettel/anytime/issues/86}{86}. As +##' pointed out in the comment in that last one, the \code{\link{Sys.time}} +##' manual page suggests several alternatives to using \sQuote{Europe/London} +##' such as \sQuote{GB}. ##' ##' @section Operating System Impact: ##' On Windows systems, accessing the \code{isdst} flag on dates or times diff --git a/man/anytime.Rd b/man/anytime.Rd index 47ac7b8..02a1b6e 100644 --- a/man/anytime.Rd +++ b/man/anytime.Rd @@ -104,7 +104,17 @@ integer value becomes numeric before our code sees it). On the other hand, \code{c(Sys.Date(), NA)} works as expected parsing as type Date with one missing value. See \href{https://github.com/eddelbuettel/anytime/issues/11}{issue -ticket 11}) for more. +ticket 11} for more. + +Another known issue concerns conversion when the timezone is set +to \sQuote{Europe/London}, see GitHub issue tickets +\href{https://github.com/eddelbuettel/anytime/issues/36}{36}. +\href{https://github.com/eddelbuettel/anytime/issues/51}{51}. +\href{https://github.com/eddelbuettel/anytime/issues/59}{59}. and +\href{https://github.com/eddelbuettel/anytime/issues/86}{86}. As +pointed out in the comment in that last one, the \code{\link{Sys.time}} +manual page suggests several alternatives to using \sQuote{Europe/London} +such as \sQuote{GB}. } \section{Operating System Impact}{ diff --git a/tests/gh_issue_84.R b/tests/gh_issue_84.R index 6197f92..3e2c5f1 100644 --- a/tests/gh_issue_84.R +++ b/tests/gh_issue_84.R @@ -1,9 +1,30 @@ -si <- sessionInfo() -if (!grepl("Fedora", si$running, ignore.case=TRUE)) { - expected <- "2018-10-01" - stopifnot(expected == format(anytime::utctime("2018-10", tz = "UTC"))) - stopifnot(expected == format(anytime::utctime("2018-10-01", tz = "UTC"))) - stopifnot(expected == format(anytime::utctime("2018-10-01 00", tz = "UTC"))) - stopifnot(expected == format(anytime::utctime("2018-10-01 00:00", tz = "UTC"))) - stopifnot(expected == format(anytime::utctime("2018-10-01 00:00:00", tz = "UTC"))) -} +## See discussion in #84 -- this is more likely an issue with Europe/London +## +## si <- sessionInfo() +## if (!grepl("Fedora", si$running, ignore.case=TRUE)) { +## expected <- "2018-10-01" +## stopifnot(expected == format(anytime::utctime("2018-10", tz = "UTC"))) +## stopifnot(expected == format(anytime::utctime("2018-10-01", tz = "UTC"))) +## stopifnot(expected == format(anytime::utctime("2018-10-01 00", tz = "UTC"))) +## stopifnot(expected == format(anytime::utctime("2018-10-01 00:00", tz = "UTC"))) +## stopifnot(expected == format(anytime::utctime("2018-10-01 00:00:00", tz = "UTC"))) +## } + + +Sys.setenv(TZ = "Europe/London") +x <- c("2016-01-01 00:00", "2016-10-01 00:00", + "2016-12-09 00:00", "2016-12-09 10:00") +anytime::utctime(x, tz = "UTC") +anytime::utctime(x, tz = "UTC", useR=TRUE) + +Sys.setenv(TZ = "UTC") +x <- c("2016-07-01 00:00", "2016-07-01 00:00", + "2016-12-09 00:00", "2016-12-09 10:00") +anytime::utctime(x, tz = "UTC") +anytime::utctime(x, tz = "UTC", useR=TRUE) + +Sys.setenv(TZ = "Australia/Melbourne") +x <- c("2016-01-01 00:00", "2016-10-01 00:00", + "2016-12-09 00:00", "2016-12-09 10:00") +anytime::utctime(x, tz = "UTC") +anytime::utctime(x, tz = "UTC", useR=TRUE)