dragosmg commented on a change in pull request #12506:
URL: https://github.com/apache/arrow/pull/12506#discussion_r828207026



##########
File path: r/R/dplyr-funcs-datetime.R
##########
@@ -189,6 +189,70 @@ register_bindings_datetime <- function() {
   })
 }
 
+register_bindings_duration <- function() {
+  register_binding("difftime", function(time1,
+                                        time2,
+                                        tz,
+                                        units = c("auto", "secs", "mins",
+                                                  "hours", "days", "weeks")) {
+    units <- match.arg(units)
+    if (units != "secs") {
+      abort("`difftime()` with units other than seconds not supported in 
Arrow")
+    }
+
+    # for time32() we do not need to worry about timezone
+    if (call_binding("is.instant", time1) & call_binding("is.instant", time2)) 
{

Review comment:
       @jonkeane It looks like removing `tz` surfaced a previously masked 
issue: casting a `POSIXct` with `build_expr("cast", ...)` somehow loses the 
timezone information. The implication being that Arrow then complains with `! 
Invalid: Subtraction of zoned and non-zoned times is ambiguous.`
   ``` r
   library(arrow, warn.conflicts = FALSE)
   a <- as.POSIXct("2022-03-07", tz = "Europe/Bucharest")
   Array$create(a)
   #> Array
   #> <timestamp[us, tz=Europe/Bucharest]>
   #> [
   #>   2022-03-06 22:00:00.000000
   #> ]
   Expression$scalar(a)
   #> Expression
   #> 2022-03-06 22:00:00.000000
   ```
   
   <sup>Created on 2022-03-16 by the [reprex 
package](https://reprex.tidyverse.org) (v2.0.1)</sup>
   




-- 
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


Reply via email to