vspinu / timechange

Efficient Updating of Date-Times
GNU General Public License v3.0
30 stars 3 forks source link

Implement `xfirst` and `xlast` to control for directional crossing of the DST gap. #23

Closed vspinu closed 1 year ago

vspinu commented 1 year ago
library(timechange)
tt <- as.POSIXct(c("2014-11-02 00:15:00", "2014-11-02 02:15:00"), tz = "America/New_York")
time_add(tt, hours = c(1, -1), roll_dst = "pre")
#> [1] "2014-11-02 01:15:00 EDT" "2014-11-02 01:15:00 EDT"
time_add(tt, hours = c(1, -1), roll_dst = "post")
#> [1] "2014-11-02 01:15:00 EST" "2014-11-02 01:15:00 EST"
time_add(tt, hours = c(1, -1), roll_dst = "xfirst")
#> [1] "2014-11-02 01:15:00 EDT" "2014-11-02 01:15:00 EST"
time_add(tt, hours = c(1, -1), roll_dst = "xlast")
#> [1] "2014-11-02 01:15:00 EST" "2014-11-02 01:15:00 EDT"

Lubridate's issue https://github.com/tidyverse/lubridate/issues/1088