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 > 2^31 seconds always gives same datetime #534

Closed
infotroph opened this issue Apr 11, 2017 · 1 comment
Closed

adding > 2^31 seconds always gives same datetime #534

infotroph opened this issue Apr 11, 2017 · 1 comment

Comments

@infotroph
Copy link
Contributor

Generating a large period works as expected:

seconds(2^31 + c(-2:2))
# [1] "2147483646S" "2147483647S" "2147483648S" "2147483649S" "2147483650S"

Adding large numbers to a POSIXt works as expected:

origin + 2^31 + c(-2:2)
# [1] "2038-01-19 03:14:06 UTC" "2038-01-19 03:14:07 UTC"
# [3] "2038-01-19 03:14:08 UTC" "2038-01-19 03:14:09 UTC"
# [5] "2038-01-19 03:14:10 UTC"

adding a large period onto a POSIXt overflows with no warning:

origin + seconds(2^31 + c(-2:2))
# [1] "2038-01-19 03:14:06 UTC" "2038-01-19 03:14:07 UTC"
# [3] "1901-12-13 20:45:52 UTC" "1901-12-13 20:45:52 UTC"
# [5] "1901-12-13 20:45:52 UTC"
@vspinu
Copy link
Member

vspinu commented Apr 11, 2017

It's likely a bug, indeed. Probably integer arithmetic is used somewhere internally. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants