You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2023/05/24 12:35:00 UTC

[GitHub] [arrow] paleolimbot commented on a diff in pull request #35671: GH-35633: [R] R builds failing with error 'Invalid: Timestamps already have a timezone: 'UTC'. Cannot localize to 'UTC''

paleolimbot commented on code in PR #35671:
URL: https://github.com/apache/arrow/pull/35671#discussion_r1204045935


##########
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:
   We don't have a naive datetime type in R...everything is timezone aware, and `tz = ""` means "your local timezone" (but everything is UTC internally). What you've encountered here is a fun type called the `POSIXlt` which is sort of like a data frame that stores components in separate vectors (the `POSIXct` is a more normal version of it, which is seconds from the unix epoch as a double vector).
   
   It's a good point that this doesn't match what base R does...I think we'd want to `cast()` if `grepl("%z")` and `assume_timezone()` otherwise?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org