jonkeane commented on code in PR #13190:
URL: https://github.com/apache/arrow/pull/13190#discussion_r891147299
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -49,50 +49,79 @@ test_df <- tibble::tibble(
test_that("strptime", {
t_string <- tibble(x = c("2018-10-07 19:04:05", NA))
- t_stamp <- tibble(x = c(lubridate::ymd_hms("2018-10-07 19:04:05"), NA))
+ # lubridate defaults to "UTC" as timezone => t_stamp is in "UTC"
+ t_stamp_with_utc_tz <- tibble(x = c(lubridate::ymd_hms("2018-10-07
19:04:05"), NA))
+ t_stamp_with_pm_tz <- tibble(
+ x = c(lubridate::ymd_hms("2018-10-07 19:04:05", tz = "Pacific/Marquesas"),
NA)
+ )
+
+ # base::strptime returns a POSIXlt (a list) => we cannot use
compare_dplyr_binding
+ # => we use expect_equal for the tests below
+
+ withr::with_timezone("Pacific/Marquesas", {
+ # the default value for strptime's `tz` argument is "", which is
interpreted
+ # as the current timezone. we test here if the strptime binding picks up
+ # correctly the current timezone (similarly to the base R version)
+ expect_equal(
+ t_string %>%
+ record_batch() %>%
+ mutate(
+ x = strptime(x, format = "%Y-%m-%d %H:%M:%S")
+ ) %>%
+ collect(),
+ t_stamp_with_pm_tz
+ )
+ })
+
+ # adding a timezone to a timezone-naive timestamp works
Review Comment:
```suggestion
# adding a timezone to a timezone-naive timestamp works
# and since our TZ when running the test is (typically) Pacific/Marquesas
# this also tests that assigning a TZ different from the current session
one
# works as expected
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]