You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/06/04 19:38:46 UTC

[GitHub] [arrow] jonkeane commented on a change in pull request #10334: ARROW-12198: [R] bindings for strptime

jonkeane commented on a change in pull request #10334:
URL: https://github.com/apache/arrow/pull/10334#discussion_r645808496



##########
File path: r/R/dplyr-functions.R
##########
@@ -338,3 +338,22 @@ get_stringr_pattern_options <- function(pattern) {
 contains_regex <- function(string) {
   grepl("[.\\|()[{^$*+?]", string)
 }
+
+nse_funcs$strptime <- function(x, format = "%Y-%m-%d %H:%M:%S", tz = NULL, unit = "ms") {
+  # Arrow uses unit for time parsing, strptime() does not.
+  # Arrow has no default option for strptime (format, unit),
+  # we suggest following format = "%Y-%m-%d %H:%M:%S", unit = MILLI/1L/"ms",
+  # (ARROW-12809)
+
+  # ParseTimestampStrptime currently ignores the timezone information (ARROW-12820).
+  # Stop if tz is provided.
+  if (is.character(tz)) {
+    arrow_not_supported("Time zone argument")
+  }
+
+  unit <- make_valid_time_unit(unit, c(valid_time64_units, valid_time32_units))
+
+  Expression$create("strptime", 
+                     x, 
+                     options = list(format = format, unit = unit))

Review comment:
       ```suggestion
     Expression$create("strptime", x, options = list(format = format, unit = unit))
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org