jonkeane commented on a change in pull request #11105:
URL: https://github.com/apache/arrow/pull/11105#discussion_r714297450
##########
File path: r/R/dplyr-functions.R
##########
@@ -672,6 +672,40 @@ nse_funcs$strptime <- function(x, format = "%Y-%m-%d
%H:%M:%S", tz = NULL, unit
Expression$create("strptime", x, options = list(format = format, unit =
unit))
}
+nse_funcs$strftime <- function(x, format = "", tz = "", usetz = FALSE) {
+ if (usetz) {
+ format <- paste(format, "%Z")
+ }
+ if (tz == "") {
+ tz <- Sys.timezone()
+ }
+ # Arrow's strftime prints in timezone of the timestamp. To match R's
strftime behavior we first
+ # cast the timestamp to desired timezone. This is a metadata only change.
+ ts <- Expression$create("cast", x, options = list(to_type =
timestamp(x$type()$unit(), tz)))
+ Expression$create("strftime", ts, options = list(format = format, locale =
Sys.getlocale("LC_TIME")))
+}
+
+ISO8601_precision_map <-
+ list(y = "%Y",
+ ym = "%Y-%m",
+ ymd = "%Y-%m-%d",
+ ymdh = "%Y-%m-%dT%H",
+ ymdhm = "%Y-%m-%dT%H:%M",
+ ymdhms = "%Y-%m-%dT%H:%M:%S")
+
+nse_funcs$format_ISO8601 <- function(x, usetz = FALSE, precision = NULL, ...) {
+ if(is.null(precision)) {
Review comment:
linting fixup
```suggestion
if (is.null(precision)) {
```
--
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]