-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I would have expected the switch from PDT to PST to occur at 2:00:00 but it is clear that this switch occurs between "2021-11-07 01:36:14" and "2021-11-07 01:36:15". Need to investigate into time theory and see why this change occurs in R at this exactly moment.
dttr2 and base R have the same behaviour on this but lubridate absolutely fails at this as it has set every
> x <- c("2021-11-07 1:00:00", "2021-11-07 1:00:01", "2021-11-07 1:35:00", "2021-11-07 1:36:00", "2021-11-07 1:36:10", "2021-11-07 1:36:14", "2021-11-07 1:36:15", "2021-11-07 1:36:30", "2021-11-07 1:36:59", "2021-11-07 1:45:00", "2021-11-07 1:59:59", "2021-11-07 2:00:00", "2021-11-07 2:30:00")
> # dttr2
> x_pst <- dtt_date_time(x, tz = "PST8PDT")
> x_pst
[1] "2021-11-07 01:00:00 PDT" "2021-11-07 01:00:01 PDT" "2021-11-07 01:35:00 PDT" "2021-11-07 01:36:00 PDT" "2021-11-07 01:36:10 PDT"
[6] "2021-11-07 01:36:14 PDT" "2021-11-07 01:36:15 PST" "2021-11-07 01:36:30 PST" "2021-11-07 01:36:59 PST" "2021-11-07 01:45:00 PST"
[11] "2021-11-07 01:59:59 PST" "2021-11-07 02:00:00 PST" "2021-11-07 02:30:00 PST"
# base R
> x_pst <- as.POSIXct(x, tz = "PST8PDT")
> x_pst
[1] "2021-11-07 01:00:00 PDT" "2021-11-07 01:00:01 PDT" "2021-11-07 01:35:00 PDT" "2021-11-07 01:36:00 PDT" "2021-11-07 01:36:10 PDT"
[6] "2021-11-07 01:36:14 PDT" "2021-11-07 01:36:15 PST" "2021-11-07 01:36:30 PST" "2021-11-07 01:36:59 PST" "2021-11-07 01:45:00 PST"
[11] "2021-11-07 01:59:59 PST" "2021-11-07 02:00:00 PST" "2021-11-07 02:30:00 PST"
# lubridate
> x_pst <- lubridate::as_datetime(x, tz = "PST8PDT")
> x_pst
[1] "2021-11-07 01:00:00 PST" "2021-11-07 01:00:01 PST" "2021-11-07 01:35:00 PST" "2021-11-07 01:36:00 PST" "2021-11-07 01:36:10 PST"
[6] "2021-11-07 01:36:14 PST" "2021-11-07 01:36:15 PST" "2021-11-07 01:36:30 PST" "2021-11-07 01:36:59 PST" "2021-11-07 01:45:00 PST"
[11] "2021-11-07 01:59:59 PST" "2021-11-07 02:00:00 PST" "2021-11-07 02:30:00 PST"
> x_pst <- lubridate::ymd_hms(x, tz = "PST8PDT")
> x_pst
[1] "2021-11-07 01:00:00 PST" "2021-11-07 01:00:01 PST" "2021-11-07 01:35:00 PST" "2021-11-07 01:36:00 PST" "2021-11-07 01:36:10 PST"
[6] "2021-11-07 01:36:14 PST" "2021-11-07 01:36:15 PST" "2021-11-07 01:36:30 PST" "2021-11-07 01:36:59 PST" "2021-11-07 01:45:00 PST"
[11] "2021-11-07 01:59:59 PST" "2021-11-07 02:00:00 PST" "2021-11-07 02:30:00 PST"
Metadata
Metadata
Assignees
Labels
No labels