Skip to content

Commit

Permalink
Fix #1174: Don't use CET and EST in tests to comply with the tzdata u…
Browse files Browse the repository at this point in the history
…pgrade
  • Loading branch information
vitalie committed Dec 1, 2024
1 parent 2f3ab32 commit 60a3a14
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Version 1.9.3.9000 (development)
==============================

### Changes
* Don't use CET and EST as timezones to accomodate the upgrade of tzdata in the R-devel


Version 1.9.3
=============
Expand Down
4 changes: 2 additions & 2 deletions R/format_ISO8601.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#' @references \url{https://en.wikipedia.org/wiki/ISO_8601}
#' @examples
#' format_ISO8601(as.Date("02-01-2018", format = "%m-%d-%Y"))
#' format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"), usetz = TRUE)
#' format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"), precision = "ymdhm")
#' format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "America/New_York"), usetz = TRUE)
#' format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "America/New_York"), precision = "ymdhm")
#' @aliases format_ISO8601,Date-method format_ISO8601,POSIXt-method format_ISO8601,Interval-method
#' format_ISO8601,Duration-method format_ISO8601,Period-method
#' @export
Expand Down
4 changes: 2 additions & 2 deletions man/format_ISO8601.Rd

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

16 changes: 8 additions & 8 deletions tests/testthat/test-format_ISO8601.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ test_that("Formatting a date works", {
})

test_that("Formatting a datetime works", {
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST")),
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "America/New_York")),
"2018-02-01T03:04:05",
info = "Standard datetime formatting works"
)
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"), usetz = TRUE),
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "America/New_York"), usetz = TRUE),
"2018-02-01T03:04:05-0500",
info = "usetz is respected with datetimes"
)
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz="EST"), usetz="Z"),
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz="America/New_York"), usetz="Z"),
"2018-02-01T08:04:05Z",
info="usetz='Z' is respected with datetimes")
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"), precision = "y"),
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "America/New_York"), precision = "y"),
"2018",
info = "precision is respected (y)"
)
# Uncertain if this is the best result; including a test so that if it changes
# the change is caught.
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"), precision = "y", usetz = TRUE),
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "America/New_York"), precision = "y", usetz = TRUE),
"2018-0500",
info = "precision is respected (y) with timezone"
)
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "EST"), precision = "ymdhm"),
expect_equal(format_ISO8601(as.POSIXct("2018-02-01 03:04:05", tz = "America/New_York"), precision = "ymdhm"),
"2018-02-01T03:04",
info = "precision is respected (ymdhm)"
)
Expand Down Expand Up @@ -125,11 +125,11 @@ test_that("Formatting an Interval works", {
"2018-02-01/2018-03-04",
info = "interval formatting respects precision (ymd)"
)
expect_equal(format_ISO8601(interval(start = "2018-02-01", end = "2018-03-04", tzone = "EST"), usetz = TRUE),
expect_equal(format_ISO8601(interval(start = "2018-02-01", end = "2018-03-04", tzone = "America/New_York"), usetz = TRUE),
"2018-02-01T00:00:00-0500/2018-03-04T00:00:00-0500",
info = "interval formatting respects timezone"
)
expect_equal(format_ISO8601(interval(start="2018-02-01", end="2018-03-04", tzone="EST"), usetz="Z"),
expect_equal(format_ISO8601(interval(start="2018-02-01", end="2018-03-04", tzone="America/New_York"), usetz="Z"),
"2018-02-01T05:00:00Z/2018-03-04T05:00:00Z",
info="interval formatting respects usetz='Z'")
})
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-parsers.R
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ test_that("AM/PM indicators are parsed correctly", {
ymd_hms("1996-12-17 04:00:00")
)
expect_equal(
parse_date_time2("12/17/1996 04:00:00 PM", "mdYHMSp", tz = "CET"),
ymd_hms("1996-12-17 16:00:00", tz = "CET")
parse_date_time2("12/17/1996 04:00:00 PM", "mdYHMSp", tz = "Europe/Berlin"),
ymd_hms("1996-12-17 16:00:00", tz = "Europe/Berlin")
)
expect_equal(
parse_date_time2("12/17/1996 04:00:00 TM", "mdYHMSp"),
Expand Down

0 comments on commit 60a3a14

Please sign in to comment.