You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into this issue while converting a real world discharge data set that was provided in PST8PDT (i.e. two 1:00:00 entries on November 07 2021). I had to manually change the second 1:00:00 entry prior to adjusting tz, which doesn't seem right...
# a date time on the eve of end of daylight savings time
x <- dtt_date_time("2021-11-06 23:00:00", tz = "PST8PDT")
# dttr2 (magically) does this correctly - assigns the first 1:00 to PDT and the second 1:00 to PST
x_dtt <- reduce(map(1:4, function(y) dtt_add_hours(x, y)), c)
x_dtt
# note this is better behaviour than lubridate so far!
# we can then successfully convert to GMT and keep the sequence
dtt_adjust_tz(x_dtt, "ETC/GMT+8")
# but when we set the tz on a vector it assigns both 1:00 to PDT
x <- c("2021-11-06 00:00:00", "2021-11-07 1:00:00", "2021-11-07 1:00:00", "2021-11-07 2:00:00")
x_pst <- dtt_date_time(x, tz = "PST8PDT")
x_pst
# same like this
x_pst <- dtt_date_time(x) |> dtt_set_tz("PST8PDT")
x_pst
# which causes this to fail (i.e. should be a continuous sequence)
dtt_adjust_tz(x_pst, tz = "ETC/GMT+8")
# to resolve we have to add an hour to the second 1:00
x_pst[3] <- dtt_add_hours(x_pst[3], 1)
dtt_adjust_tz(x_pst, tz = "ETC/GMT+8")
The text was updated successfully, but these errors were encountered:
This behaviour does match the intention of the function since a vector of strings is passed there is no way to tell whether the value should be PST or PDT if the values are independent (not a series). This means that the PST or PDT needs to be assigned consistently to string values and it appears that "2021-11-07 1:00:00" is coded with PDT and "2021-11-07 2:00:00" is coded with PST. This is unfortunately a limitation but is unavoidable when converting a string based on how time/timezones/daylight savings works.
This scenario can be common with various types of data and so users need to be aware of this issue.
I ran into this issue while converting a real world discharge data set that was provided in PST8PDT (i.e. two 1:00:00 entries on November 07 2021). I had to manually change the second 1:00:00 entry prior to adjusting tz, which doesn't seem right...
The text was updated successfully, but these errors were encountered: