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

Time.at broken for huge timestamps #1304

Closed
grddev opened this issue Dec 5, 2013 · 2 comments
Closed

Time.at broken for huge timestamps #1304

grddev opened this issue Dec 5, 2013 · 2 comments

Comments

@grddev
Copy link
Contributor

grddev commented Dec 5, 2013

The behaviour of Time.at is inconsistent in MRI and JRuby.

# jruby 1.7.6
Time.at(2**59) # => 146140482-04-24 17:36:27 +0200
Time.at(2**60) # => -292275055-05-16 17:59:16 +0112
Time.at(2**61) # => 1970-01-01 01:00:00 +0100
Time.at(2**63) # RangeError: bignum too big to convert into `long'
# mri 1.9.3-p327
Time.at(2**59) # => 18267316009-03-08 07:58:08 +0100
Time.at(2**60) # => 36534630048-05-13 15:56:16 +0200
Time.at(2**61) # => 73069258126-09-25 05:52:32 +0200
Time.at(2**63) # => 292277026596-12-04 16:30:08 +0100

Since JRuby uses joda-time, which represents times using a signed long of milliseconds, it is impossible to represents Times larger than roughly (2**63-1)/1000 seconds.

It is not clear to me whether adding support for this in JRuby would be worthwhile, I would argue that raising a specific exception for timestamps beyond the limit would be a lot better than the above seemingly random behaviour.

@rtyler rtyler added the core label Aug 7, 2015
@rtyler
Copy link

rtyler commented Aug 7, 2015

With JRuby 9k this issue exists, with an additional exception:

[15] pry(main)> Time.at(2**59)
=> 146140482-04-24 08:36:27 -0700
[16] pry(main)> Time.at(2**60)
RangeError: Adding time zone offset caused overflow
from org/jruby/RubyTime.java:1053:in `at'
[17] pry(main)> Time.at(2**61)
=> 1969-12-31 16:00:00 -0800
[18] pry(main)> Time.at(2**63)
RangeError: bignum too big to convert into `long'
from org/jruby/RubyTime.java:1027:in `at'
[19] pry(main)> 

@enebo
Copy link
Member

enebo commented May 17, 2017

It is a compatibility difference but one I do not see anyone hitting in real life and our hands are tied by joda time not working for unlimited precision. So I think WONTFIX :|

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

No branches or pull requests

4 participants