eitsupi commented on code in PR #14093:
URL: https://github.com/apache/arrow/pull/14093#discussion_r1062046076
##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -429,6 +430,58 @@ register_bindings_datetime_conversion <- function() {
})
}
+register_bindings_datetime_timezone <- function() {
+ register_binding(
+ "lubridate::force_tz",
+ function(time, tzone = "", roll_dst = "error") {
+ if (!identical(roll_dst, "error")) {
+ arrow_not_supported("`roll_dst`")
+ }
+
+ 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(), "`")
+ )
+ }
+
+ # Remove timezone if needed
+ current_unit <- time$type()$unit()
+ time <- cast(time, timestamp(current_unit, ""))
+
+ # Add timezone
+ Expression$create(
+ "assume_timezone",
+ time,
+ options = list(
+ timezone = tzone
+ )
+ )
+ },
+ notes = c(
+ "Timezone conversion from non-UTC timezone not supported;",
+ "roll_dst = 'NA' is not supported: use 'error', 'pre', or 'post'"
Review Comment:
Perhaps support only `'error'` now?
--
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]