dragosmg commented on a change in pull request #12357: URL: https://github.com/apache/arrow/pull/12357#discussion_r807292334
########## File path: r/R/dplyr-funcs-datetime.R ########## @@ -147,5 +147,15 @@ register_bindings_datetime <- function() { register_binding("pm", function(x) { !call_binding("am", x) }) - + register_binding("tz", function(x) { + if (call_binding("is.Date", x)) { + abort("timezone extraction for objects of class `date` not supported in Arrow") + } else if (call_binding("is.numeric", x)) { + abort("timezone extraction for objects of class `numeric` not supported in Arrow") + } else if (call_binding("is.character", x)) { + abort("timezone extraction for objects of class `character` not supported in Arrow") + } else { + return(x$type()$timezone()) + } Review comment: TIL `...$ToString()`. I really like your suggestion. I thought of something like it and couldn't figure out how exactly to implement it. I guess the only limitation is that we will now surface the arrow data types instead of the matching R ones, which might cause confusion. ########## File path: r/tests/testthat/test-dplyr-funcs-datetime.R ########## @@ -711,3 +711,71 @@ test_that("am/pm mirror lubridate", { ) }) + +test_that("extract tz", { + df <- tibble( + x = as.POSIXct(c("2022-02-07", "2022-02-10"), tz = "Pacific/Marquesas"), + #lubridate::tz() returns -for the time being - "UTC" for NAs, strings, + #dates and numerics + y = c("2022-02-07", NA), + z = as.Date(c("2022-02-07", NA)), + w = c(1L, 5L), + v = c(1.1, 2.47) Review comment: Done. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org