-
Notifications
You must be signed in to change notification settings - Fork 213
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior
Description
Apologies if this is a repeated issue, this seems slightly different from other DST bugs I saw reported.
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:base':
#>
#> date
x <- ymd_hms("2017-11-05 23:59:03", tz = 'America/New_York')
x
#> [1] "2017-11-05 23:59:03 EST"
ceiling_date(x, 'day')
#> [1] "2017-11-05 23:00:00 EST"The issue arises in round.r line 253 when a "days" worth of seconds is added to 2017-11-05.
Because of DST ending, 2017-11-05 has 25 hours but ceiling_date(x, 'day') only adds 86400 seconds (24 hours).
y <- floor_date(x, 'day')
# Not what I expected, but accurate
y + 86400
#> [1] "2017-11-05 23:00:00 EST"
# What I expected, seems accurate
y + days(1)
#> [1] "2017-11-06 EST"
# What I expected, but not accurate?
y + hours(24)
#> [1] "2017-11-06 EST"
# Hacky work-around
floor_date(x, 'day') + days(1)
#> [1] "2017-11-06 EST"
# Same for 2016, 2015...
ceiling_date(ymd_hm('2016-11-06 23:59', tz = 'America/New_York'), 'day')
#> [1] "2016-11-06 23:00:00 EST"
ceiling_date(ymd_hm('2015-11-01 23:59', tz = 'America/New_York'), 'day')
#> [1] "2015-11-01 23:00:00 EST"
# DST is overrated ¯\_(ツ)_/¯Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior