ianmcook commented on a change in pull request #11592:
URL: https://github.com/apache/arrow/pull/11592#discussion_r743027283
##########
File path: r/R/dplyr-functions.R
##########
@@ -848,6 +844,21 @@ nse_funcs$wday <- function(x,
Expression$create("day_of_week", x, options = list(count_from_zero = FALSE,
week_start = week_start))
}
+nse_funcs$is.Date <- function(x) {
+ inherits(x, "Date") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("DATE32")])
+}
+
+nse_funcs$is.instant <- nse_funcs$is.timepoint <- function(x) {
+ inherits(x, c("POSIXt", "Date")) ||
Review comment:
For exact parity with lubridate, this would be
```suggestion
inherits(x, c("POSIXt", "POSIXct", "POSIXlt", "Date")) ||
```
(https://github.com/tidyverse/lubridate/blob/9cece5680d0280c5cd1ccdbc9309ccb4724b3a34/R/instants.r#L15)
##########
File path: r/R/dplyr-functions.R
##########
@@ -848,6 +844,21 @@ nse_funcs$wday <- function(x,
Expression$create("day_of_week", x, options = list(count_from_zero = FALSE,
week_start = week_start))
}
+nse_funcs$is.Date <- function(x) {
+ inherits(x, "Date") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("DATE32")])
+}
+
+nse_funcs$is.instant <- nse_funcs$is.timepoint <- function(x) {
+ inherits(x, c("POSIXt", "POSIXct", "POSIXlt", "Date")) ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("TIMESTAMP",
"DATE32")])
+}
+
+nse_funcs$is.POSIXct <- function(x) {
+ inherits(x, "POSIXct") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("TIMESTAMP")])
+}
+
Review comment:
Should we add a binding for `is.POSIXt()`? It's defined in lubridate as
`inherits(x, "POSIXt")`
##########
File path: r/R/dplyr-functions.R
##########
@@ -848,6 +844,21 @@ nse_funcs$wday <- function(x,
Expression$create("day_of_week", x, options = list(count_from_zero = FALSE,
week_start = week_start))
}
+nse_funcs$is.Date <- function(x) {
+ inherits(x, "Date") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("DATE32")])
+}
+
+nse_funcs$is.instant <- nse_funcs$is.timepoint <- function(x) {
+ inherits(x, c("POSIXt", "POSIXct", "POSIXlt", "Date")) ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("TIMESTAMP",
"DATE32")])
+}
+
+nse_funcs$is.POSIXct <- function(x) {
+ inherits(x, "POSIXct") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("TIMESTAMP")])
+}
+
Review comment:
Likewise with `is.POSIXlt()` which is defined in lubridate as
`inherits(x, "POSIXlt")`
##########
File path: r/R/dplyr-functions.R
##########
@@ -848,6 +844,21 @@ nse_funcs$wday <- function(x,
Expression$create("day_of_week", x, options = list(count_from_zero = FALSE,
week_start = week_start))
}
+nse_funcs$is.Date <- function(x) {
+ inherits(x, "Date") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("DATE32")])
+}
+
+nse_funcs$is.instant <- nse_funcs$is.timepoint <- function(x) {
+ inherits(x, c("POSIXt", "POSIXct", "POSIXlt", "Date")) ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("TIMESTAMP",
"DATE32")])
+}
+
+nse_funcs$is.POSIXct <- function(x) {
+ inherits(x, "POSIXct") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("TIMESTAMP")])
+}
+
Review comment:
Oh, I didn't see your other comments about this. Disregard this.
##########
File path: r/R/dplyr-functions.R
##########
@@ -848,6 +844,21 @@ nse_funcs$wday <- function(x,
Expression$create("day_of_week", x, options = list(count_from_zero = FALSE,
week_start = week_start))
}
+nse_funcs$is.Date <- function(x) {
+ inherits(x, "Date") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("DATE32")])
+}
+
+nse_funcs$is.instant <- nse_funcs$is.timepoint <- function(x) {
+ inherits(x, c("POSIXt", "POSIXct", "POSIXlt", "Date")) ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("TIMESTAMP",
"DATE32")])
+}
+
+nse_funcs$is.POSIXct <- function(x) {
+ inherits(x, "POSIXct") ||
+ (inherits(x, "Expression") && x$type_id() %in% Type[c("TIMESTAMP")])
+}
+
Review comment:
Oh, I didn't see your other comments about `is.POSIXlt()`. Disregard
that. I'm still not sure about `is.POSIXt()` though.
--
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]