dragosmg commented on code in PR #13506:
URL: https://github.com/apache/arrow/pull/13506#discussion_r930151838


##########
r/R/dplyr-datetime-helpers.R:
##########
@@ -240,25 +214,24 @@ build_formats <- function(orders) {
 #' @noRd
 build_format_from_order <- function(order) {
   char_list <- list(
-    "y" = c("%y", "%Y"),
-    "m" = c("%m", "%B", "%b"),
-    "d" = "%d",
-    "H" = "%H",
-    "M" = "%M",
-    "S" = "%S",
-    "I" = "%I"
+    "%T" = "%H-%M-%S",
+    "%y" = c("%y", "%Y"),
+    "%m" = c("%m", "%B", "%b"),
+    "%b" = c("%m", "%B", "%b")
   )
 
-  split_order <- strsplit(order, split = "")[[1]]
+  formats <- stringr::str_extract_all(order, "%{0,1}(O*[a-zA-Z])")[[1]]

Review Comment:
   We currently do not depend on {stringr} - i.e. `stringr` is not listed under 
`Imports` in DESCRIPTION. I'm not sure it's worth the extra dependency for a 
single function call, which we could reproduce with base R functions.
   
   Moreover, the regex starts with match `%` 0 or 1 times in orders, given that 
we strip anything that is not a letter with:
   
https://github.com/apache/arrow/blob/bbf249e056315af0a18d5c0834de9adef117a25f/r/R/dplyr-datetime-helpers.R#L166
   , I don't think that regex is entirely needed. 



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