You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "eitsupi (via GitHub)" <gi...@apache.org> on 2024/03/01 15:03:36 UTC

[I] [R] How to convert the timestamp without time zone type to the POSIXct type ideally? [arrow]

eitsupi opened a new issue, #40309:
URL: https://github.com/apache/arrow/issues/40309

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   The POSIXct type in R seems to behave in the absence of time zone information in such a way that it is interpreted as the time zone time in which the R session is running.
   
   However, the arrow package does not consider the time zone of the R session when converting from the Arrow timestamp type to the POSIXct type.
   
   ``` r
   library(arrow)
   #>
   #> Attaching package: 'arrow'
   #> The following object is masked from 'package:utils':
   #>
   #>     timestamp
   
   Sys.setenv(TZ = "UTC")
   
   x <- "1900-01-01"
   a_a <- chunked_array(as.POSIXct(x), type = timestamp())
   a_a
   #> ChunkedArray
   #> <timestamp[s]>
   #> [
   #>   [
   #>     1900-01-01 00:00:00
   #>   ]
   #> ]
   
   out <- as.vector(a_a)
   
   as.POSIXct(x)
   #> [1] "1900-01-01 UTC"
   unclass(as.POSIXct(x))
   #> [1] -2208988800
   #> attr(,"tzone")
   #> [1] ""
   out
   #> [1] "1900-01-01 UTC"
   unclass(out)
   #> [1] -2208988800
   
   Sys.setenv(TZ = "Europe/Paris")
   
   as.POSIXct(x)
   #> [1] "1900-01-01 PMT"
   unclass(as.POSIXct(x))
   #> [1] -2208989361
   #> attr(,"tzone")
   #> [1] ""
   out
   #> [1] "1900-01-01 00:09:21 PMT"
   unclass(out)
   #> [1] -2208988800
   ```
   
   <sup>Created on 2024-03-01 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup>
   
   Is there a reason why this behavior was chosen? Or is this a bug and should be fixed? (which is, of course, a breaking change).
   
   I found this behavior in this issue (pola-rs/r-polars#875)
   
   ### Component(s)
   
   R


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

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