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


##########
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:
   Indeed `%` is already removed in `build_formats`, removing.
   Also switching `str_extract_all` to:
   ```R
   formats <- regmatches(order, gregexpr("(O{0,1}[a-zA-Z])", order))[[1]]
   ```
   
   I do think we need regex to keep `O{format_letter}` formats intact 
(otherwise `"Om"` -> `c("O", "m")`).
   Lubridate also [does test for the O 
prefix](https://github.com/tidyverse/lubridate/blob/main/tests/testthat/test-parsers.R#L807).



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