Skip to content

Commit

Permalink
small addition to help page for Europe/London issue #84
Browse files Browse the repository at this point in the history
as well as at least three other (referenced) issues
  • Loading branch information
eddelbuettel committed Dec 9, 2018
1 parent 8449640 commit 375e77c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
14 changes: 12 additions & 2 deletions R/anytime.R
Original file line number Diff line number Diff line change
@@ -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.
##
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion man/anytime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 30 additions & 9 deletions tests/gh_issue_84.R
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 375e77c

Please sign in to comment.