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



##########
File path: r/R/dplyr-funcs-datetime.R
##########
@@ -140,3 +140,25 @@ register_bindings_datetime <- function() {
     (year %% 4 == 0) & ((year %% 100 != 0) | (year %% 400 == 0))
   })
 }
+
+binding_format_datetime <- function(x, format = "", tz = "", usetz = FALSE) {
+  if (usetz) {
+    format <- paste(format, "%Z")
+  }
+
+  if (call_binding("is.POSIXct", x)) {
+    # the casting part might not be required once
+    # https://issues.apache.org/jira/browse/ARROW-14442 is solved
+    # TODO revisit the steps below once the PR for that issue is merged
+    if (tz == "" && x$type()$timezone() != "") {
+      tz <- x$type()$timezone()
+    } else if (tz == "") {
+      tz <- Sys.timezone()
+    }
+    ts <- Expression$create("cast", x, options = list(to_type = 
timestamp(x$type()$unit(), tz)))
+  } else {
+    ts <- x
+  }

Review comment:
       Sure. 

##########
File path: r/R/dplyr-funcs-datetime.R
##########
@@ -140,3 +140,25 @@ register_bindings_datetime <- function() {
     (year %% 4 == 0) & ((year %% 100 != 0) | (year %% 400 == 0))
   })
 }
+
+binding_format_datetime <- function(x, format = "", tz = "", usetz = FALSE) {
+  if (usetz) {
+    format <- paste(format, "%Z")
+  }
+
+  if (call_binding("is.POSIXct", x)) {
+    # the casting part might not be required once
+    # https://issues.apache.org/jira/browse/ARROW-14442 is solved
+    # TODO revisit the steps below once the PR for that issue is merged
+    if (tz == "" && x$type()$timezone() != "") {
+      tz <- x$type()$timezone()
+    } else if (tz == "") {
+      tz <- Sys.timezone()
+    }
+    ts <- Expression$create("cast", x, options = list(to_type = 
timestamp(x$type()$unit(), tz)))
+  } else {
+    ts <- x
+  }

Review comment:
       Sure. 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to