diff --git a/r/NEWS.md b/r/NEWS.md index 20cae164445..c74916bf8cf 100644 --- a/r/NEWS.md +++ b/r/NEWS.md @@ -22,6 +22,7 @@ * `lubridate`: * `tz()` to extract/get timezone * `semester()` to extract/get semester + * `dst()` to get daylight savings time indicator. # arrow 7.0.0 diff --git a/r/R/expression.R b/r/R/expression.R index 0e71803ec97..224a46745e8 100644 --- a/r/R/expression.R +++ b/r/R/expression.R @@ -62,6 +62,7 @@ # date and time functions "day" = "day", + "dst" = "is_dst", "hour" = "hour", "isoweek" = "iso_week", "epiweek" = "us_week", diff --git a/r/tests/testthat/test-dplyr-funcs-datetime.R b/r/tests/testthat/test-dplyr-funcs-datetime.R index c5de2684c02..2cc76d36f7a 100644 --- a/r/tests/testthat/test-dplyr-funcs-datetime.R +++ b/r/tests/testthat/test-dplyr-funcs-datetime.R @@ -784,5 +784,20 @@ test_that("semester works with temporal types and integers", { collect(), regexp = "NotImplemented: Function 'month' has no kernel matching input types (array[string])", fixed = TRUE + ) + }) + +test_that("dst extracts daylight savings time correctly", { + test_df <- tibble( + dates = as.POSIXct(c("2021-02-20", "2021-07-31", "2021-10-31", "2021-01-31"), tz = "Europe/London") + ) + # https://issues.apache.org/jira/browse/ARROW-13168 + skip_on_os("windows") + + compare_dplyr_binding( + .input %>% + mutate(dst = dst(dates)) %>% + collect(), + test_df ) })