Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ceiling_date rounding by day on DST change rounds to 23:00 #605

Closed
gadenbuie opened this issue Nov 6, 2017 · 1 comment
Closed

ceiling_date rounding by day on DST change rounds to 23:00 #605

gadenbuie opened this issue Nov 6, 2017 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@gadenbuie
Copy link
Contributor

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 ¯\_(ツ)_/¯
@vspinu
Copy link
Member

vspinu commented Nov 6, 2017

Thanks for the identification. An update is needed there indeed.

@vspinu vspinu added the bug an unexpected problem or unintended behavior label Nov 6, 2017
@vspinu vspinu closed this as completed in c061796 Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants