Arithmetic with different Time Zones/Day Light Savings

3 views
Skip to first unread message

Fredo XVII

unread,
Dec 13, 2018, 12:44:39 PM12/13/18
to lubridate
Hello,

I have time stamps in different time zones, and I am subtracting (%--%) them to get the interval between the 2 time periods.  

My question is, if the time stamp has the time zone local to the time stamp, when I subtract the time stamp from a location in a different time zone, will %--% account for the differences in time zones?

Will it also account for changes in Day Light Savings time? So for example if my destination is Arizona and my origination is Colorado, will my the duration calculate a similar duration during the day light savings?

Thank you!

Alfredo

 

Fredo XVII

unread,
Dec 13, 2018, 3:29:19 PM12/13/18
to lubridate
I believe I figured it out.  See below:

#UTC duration: "106236s (~1.23 days)", 29.51 hours
ymd_hms("2018-12-01 00:36:18") %--% ymd_hms("2018-12-02 06:06:54") %>% as.duration() / lubridate::dhours(1)

# Local time zones: "109836s (~1.27 days)", 30.51 hours
ymd_hms("2018-12-01 00:36:18",tz = "America/Indiana/Indianapolis") %--% ymd_hms("2018-12-02 06:06:54", tz = "America/Chicago") %>% as.duration() / lubridate::dhours(1)

The local time is the correct duration, so the interval does take into account the time zone.  

Thanks,

Alfredo
Reply all
Reply to author
Forward
0 new messages