dragosmg commented on code in PR #13627:
URL: https://github.com/apache/arrow/pull/13627#discussion_r924875872
##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -571,11 +571,20 @@ register_bindings_datetime_parsers <- function() {
}
})
- ymd_parser_vec <- c("ymd", "ydm", "mdy", "myd", "dmy", "dym", "ym", "my",
"yq")
+ parser_vec <- c(
+ "ymd", "ydm", "mdy", "myd", "dmy", "dym", "ym", "my", "yq",
+ "ymd_HMS", "ymd_HM", "ymd_H", "dmy_HMS", "dmy_HM", "dmy_H",
+ "mdy_HMS", "mdy_HM", "mdy_H", "ydm_HMS", "ydm_HM", "ydm_H"
+ )
- ymd_parser_map_factory <- function(order) {
+ parser_map_factory <- function(order) {
force(order)
function(x, tz = NULL) {
Review Comment:
`lubridate::parse_date_time()` has a `truncated` argument (which we also
support with the `parse_date_time` binding). What do you think about exposing
it to the `ymd_...()` family of functions? The same goes for `quiet` where the
binding has a different default (is not chatty, `quiet = TRUE`).
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -2474,4 +2534,24 @@ test_that("build_formats() and
build_format_from_order()", {
"%y%b%d%H%M%S", "%Y%b%d%H%M%S"
)
)
+
+ expect_equal(
+ build_format_from_order("ymdHM"),
+ c(
+ "%y-%m-%d-%H-%M", "%Y-%m-%d-%H-%M", "%y-%B-%d-%H-%M",
+ "%Y-%B-%d-%H-%M", "%y-%b-%d-%H-%M", "%Y-%b-%d-%H-%M",
+ "%y%m%d%H%M", "%Y%m%d%H%M", "%y%B%d%H%M", "%Y%B%d%H%M",
+ "%y%b%d%H%M", "%Y%b%d%H%M"
+ )
+ )
+
+ expect_equal(
+ build_format_from_order("ymdH"),
+ c(
+ "%y-%m-%d-%H", "%Y-%m-%d-%H", "%y-%B-%d-%H",
+ "%Y-%B-%d-%H", "%y-%b-%d-%H", "%Y-%b-%d-%H",
+ "%y%m%d%H", "%Y%m%d%H", "%y%B%d%H", "%Y%B%d%H",
+ "%y%b%d%H", "%Y%b%d%H"
+ )
+ )
})
Review Comment:
Maybe in a separate `test_that` block we could have a few parsing tests with
regular R objects. That's totally on me as I should've added them a while ago.
For example, something like:
```r
compare_dplyr_binding(
.input %>%
mutate(
ymd_hms_dttm = ymd_hms("2022-07-19 20:24:43"),
...
) %>%
collect(),
test_dates_times2
)
```
--
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]