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

Adding 10 seconds to any date with 20:59:50 results in NA #188

Closed
mdagost opened this issue May 20, 2013 · 3 comments
Closed

Adding 10 seconds to any date with 20:59:50 results in NA #188

mdagost opened this issue May 20, 2013 · 3 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@mdagost
Copy link

mdagost commented May 20, 2013

I encountered something odd today, which looks to me like a bug. I had been running R 2.15.2 with lubridate_1.2.0, I can do the following normal thing:

ymd_hms('2013-05-01 20:59:50')+seconds(10)
[1] "2013-05-01 21:00:00 UTC"

However, with R 3.0.0 and lubridate_1.3.0, I get the following:

ymd_hms('2013-05-01 20:59:50')+seconds(10)
[1] NA

I get an NA for any date that I try as long as the timestamp is 20:59:50 and I add seconds(10). Actually, it looks like I get an NA for any timestamp (like 20:59:30) and interval combo in seconds (like seconds(30)) that would have a resulting timestamp of 21:00:00. If the interval is in minutes or hours, it works though:

ymd_hms('2013-05-01 20:00:00')+hours(1)
[1] "2013-05-01 21:00:00 UTC"
ymd_hms('2013-05-01 20:50:00')+minutes(10)
[1] "2013-05-01 21:00:00 UTC"

Any ideas?

Michelangelo

@mdagost
Copy link
Author

mdagost commented May 21, 2013

So I've done a little digging. The bug persists in the latest R and the lubridate master.

It looks to me like the bug is coming from this piece of code:

https://github.com/hadley/lubridate/blob/master/R/update.r#L141-L148

For the first example above, chours=21 and lhours=20. That causes this to run:

ct[chours != lhours] <- NA

If I comment that line out, the first example works with the latest version of R and the lubridate master.

Looks like that code was added in with this commit last month by @garrettgman to fix a DST issue:

8056471

I don't know enough about what the DST code is doing, but I think I've at least localized the bug to that bit.

@garrettgman
Copy link
Member

Looks like a bug. Thanks.

@vspinu vspinu added the bug an unexpected problem or unintended behavior label Dec 14, 2014
@vspinu
Copy link
Member

vspinu commented Apr 23, 2015

Finally fixed in 7941df8. This report was duplicated in #217 and #313.

@vspinu vspinu closed this as completed Apr 23, 2015
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

3 participants