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

NA when adding 60 seconds to date times with 59 minutes #313

Closed
garrettgman opened this Issue Apr 22, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@garrettgman
Member

garrettgman commented Apr 22, 2015

Adding seconds returns NAs when result has new hour and zero seconds

library(lubridate)
ymd_hms("2015-01-01 00:59:00") + seconds(60)
## [1] NA
ymd_hms("2015-01-01 01:59:00") + seconds(60)
## [1] NA
ymd_hms("2015-01-01 23:59:00") + seconds(60)
## [1] NA
ymd_hms("2015-01-01 00:59:05") + seconds(55)
## [1] NA
ymd_hms("2015-01-01 00:59:59") + seconds(1)
## [1] NA

Doing the equivalent with minutes(1) works

ymd_hms("2015-01-01 00:59:00") + minutes(1)
## [1] "2015-01-01 01:00:00 UTC"
ymd_hms("2015-01-01 01:59:00") + minutes(1)
## [1] "2015-01-01 02:00:00 UTC"
ymd_hms("2015-01-01 23:59:00") + minutes(1)
## [1] "2015-01-02 UTC"

NA only occurs when result has new hour and zero seconds

ymd_hms("2015-01-01 00:59:00") + seconds(59)
## [1] "2015-01-01 00:59:59 UTC"
ymd_hms("2015-01-01 00:59:00") + seconds(61)
## [1] "2015-01-01 01:00:01 UTC"
ymd_hms("2015-01-01 00:58:00") + seconds(60)
## [1] "2015-01-01 00:59:00 UTC" 

NA does not occur when adding more than 60 seconds to create new hour and zero seconds

ymd_hms("2015-01-01 00:58:59") + seconds(61)
## [1] "2015-01-01 01:00:00 UTC"
ymd_hms("2015-01-01 00:58:55") + seconds(65)
## [1] "2015-01-01 01:00:00 UTC"
ymd_hms("2015-01-01 23:58:00") + seconds(120)
## [1] "2015-01-02 UTC"
@stevencb

This comment has been minimized.

Show comment
Hide comment
@stevencb

stevencb Apr 22, 2015

This bug is probably related to what was reported in issue #217.

stevencb commented Apr 22, 2015

This bug is probably related to what was reported in issue #217.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment