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

With period arythmetics crossing DST repeated times should behave symmetrically for addition and subtraction #1088

Open vspinu opened 1 year ago

vspinu commented 1 year ago

With addition the rule is that the pre-transition time is used. I think it's natural with substraction to use post-transition time for consistency

Followup from #759

library(lubridate, warn.conflicts = F)
#> Loading required package: timechange
(dt <- ymd_hms("2021-04-04 00:15:00", tz = "Pacific/Auckland"))
#> [1] "2021-04-04 00:15:00 NZDT"
(st <- ymd_hms("2021-04-04 03:15:00", tz = "Pacific/Auckland"))
#> [1] "2021-04-04 03:15:00 NZST"
dt + hours(1)
#> [1] "2021-04-04 01:15:00 NZDT"
st - hours(1)
#> [1] "2021-04-04 02:15:00 NZDT"