thisisnic commented on code in PR #14093:
URL: https://github.com/apache/arrow/pull/14093#discussion_r1068130015
##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -429,6 +430,78 @@ register_bindings_datetime_conversion <- function() {
})
}
+register_bindings_datetime_timezone <- function() {
+ register_binding(
+ "lubridate::force_tz",
+ function(time, tzone = "", roll_dst = c("error", "post")) {
+ if (length(roll_dst) == 1L) {
+ roll_dst <- c(roll_dst, roll_dst)
+ } else if (length(roll_dst) != 2L) {
+ arrow_not_supported("`roll_dst` length != 1 or 2")
+ }
+
+ nonexistent <- switch(
+ roll_dst[1],
+ "error" = 0L,
+ "boundary" = 2L,
+ arrow_not_supported("`roll_dst` != 'error' or 'boundary' for
nonexistent times")
+ )
+
+ ambiguous <- switch(
+ roll_dst[2],
+ "error" = 0L,
+ "pre" = 1L,
+ "post" = 2L,
+ arrow_not_supported("`roll_dst` != 'error', 'pre', or 'post' for
ambiguous times")
+ )
+
+ if (identical(tzone, "")) {
+ tzone <- Sys.timezone()
+ }
+
+ if (!inherits(time, "Expression")) {
+ time <- Expression$scalar(time)
+ }
+
+ # Non-UTC timezones don't work here and getting them to do so was too
+ # hard to do in the initial PR because there is no way in Arrow to
+ # "unapply" a UTC offset (i.e., the reverse of assume_timezone).
+ if (!time$type()$timezone() %in% c("", "UTC")) {
+ arrow_not_supported(
+ paste0("force_tz() from timezone `", time$type()$timezone(), "`")
+ )
Review Comment:
Perfect!
--
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]