Skip to content

Commit

Permalink
test: add tests with timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Mar 2, 2024
1 parent ec868aa commit ded6d13
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/testthat/test-as_polars.R
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,20 @@ patrick::with_parameters_test_that("clock package class support",
as.POSIXct(as.vector(pl_sys_time), tz = "Asia/Kolkata"),
as.POSIXct(clock_sys_time, tz = "Asia/Kolkata")
)

# Test on other time zone
withr::with_envvar(
new = c(TZ = "Europe/Paris"),
{
expect_equal(as.POSIXct(as.vector(pl_naive_time)), as.POSIXct(clock_naive_time))
expect_equal(as.POSIXct(as.vector(pl_zoned_time_1)), as.POSIXct(clock_zoned_time_1))
expect_equal(as.POSIXct(as.vector(pl_sys_time)), as.POSIXct(clock_sys_time, tz = "UTC"))
expect_equal(
as.POSIXct(as.vector(pl_sys_time), tz = "Asia/Kolkata"),
as.POSIXct(clock_sys_time, tz = "Asia/Kolkata")
)
}
)
},
precision = c("nanosecond", "microsecond", "millisecond", "second", "minute", "hour", "day"),
.test_name = precision
Expand Down

0 comments on commit ded6d13

Please sign in to comment.