tidyverse / lubridate

Make working with dates in R just that little bit easier
https://lubridate.tidyverse.org
GNU General Public License v3.0
728 stars 207 forks source link

coercing a datetime to a datetime loses timezone #1085

Closed mkoohafkan closed 1 year ago

mkoohafkan commented 1 year ago

a POSIX*t object's timezone is lost when it is coerced to a POSIX*t object using as_datetime():

x = as.POSIXct("2022-01-01 23:40:36", tz = "US/Pacific")
as_datetime(x)
## [1] "2022-01-02 07:40:36 UTC"
identical(x, as_datetime(x))
## [1] FALSE

# not the case with as.POSIXct
identical(x, as.POSIXct(x))
## [1] TRUE
vspinu commented 1 year ago

Thanks for reporting this!