paleolimbot commented on code in PR #35671:
URL: https://github.com/apache/arrow/pull/35671#discussion_r1204056042
##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -61,12 +61,14 @@ register_bindings_datetime_utility <- function() {
tz <- Sys.timezone()
}
- # if a timestamp does not contain timezone information (i.e. it is
+ # If a timestamp does not contain timezone information (i.e. it is
# "timezone-naive") we can attach timezone information (i.e. convert it
into
# a "timezone-aware" timestamp) with `assume_timezone`
# if we want to cast to a different timezone, we can only do it for
- # timezone-aware timestamps, not for timezone-naive ones
- if (!is.null(tz)) {
+ # timezone-aware timestamps, not for timezone-naive ones.
+ # strptime in Acero will return a timezone-aware timestamp if %z is
+ # part of the format string.
+ if (!is.null(tz) && !grepl("%z", format, fixed = TRUE)) {
Review Comment:
I don't know if this helps with understanding dates/times in R, but the `tz`
argument won't affect the underlying point in time (just the attribute of the
output and, to great confusion of many, how it is printed):
``` r
unclass(as.POSIXct(strptime("2020-05-01T00:00+0100",
format="%Y-%m-%dT%H:%M%z")))
#> [1] 1588287600
#> attr(,"tzone")
#> [1] ""
unclass(as.POSIXct(strptime("2020-05-01T00:00+0100", tz = "UTC",
format="%Y-%m-%dT%H:%M%z")))
#> [1] 1588287600
#> attr(,"tzone")
#> [1] "UTC"
unclass(as.POSIXct(strptime("2020-05-01T00:00+0100", tz = "America/Halifax",
format="%Y-%m-%dT%H:%M%z")))
#> [1] 1588287600
#> attr(,"tzone")
#> [1] "America/Halifax"
```
<sup>Created on 2023-05-24 with [reprex
v2.0.2](https://reprex.tidyverse.org)</sup>
--
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]