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.now + bignum incorrect #1779

Closed
joevandyk opened this issue Jul 1, 2014 · 9 comments
Closed

Time.now + bignum incorrect #1779

joevandyk opened this issue Jul 1, 2014 · 9 comments
Labels

Comments

@joevandyk
Copy link

irb(main):061:0> Time.now + 7819128400
=> 2262-04-11 16:46:19 -0700

irb(main):062:0> Time.now + 7819128500
=> 1677-09-20 16:20:34 -0752 # time travel to past!
@mkristian
Copy link
Member

???

which jruby version did you use. a quick test with jruby-1.7.12 showed the
same results as mri-2.1

@joevandyk
Copy link
Author

Maybe try a bigger number? It might depend on your time. I'm using jruby-1.7.3, and also noticed the problem on whatever version of jruby travis-ci uses.

$ ruby -v
jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_45-b18 +indy [darwin-x86_64]

$ irb
irb(main):001:0> Time.now + 7819128400
=> 1677-09-21 13:53:37 -0752

@mkristian mkristian added this to the Invalid or Duplicate milestone Jul 2, 2014
@mkristian
Copy link
Member

hmm - that is fixed from jruby-1.7.5 onwards. 1.7.3 feels really old by now ;)

regarding travis I guess you have to report it to there. I did see travis running old jruby versions somewhere before.

@joevandyk
Copy link
Author

I get different results from jruby-1.7.5 onwards, but not correct results.

MRI:
irb(main):001:0> Time.now + 78191284000
=> 4492-04-13 03:44:55 -0700

JRuby 1.7.13:
irb(main):001:0> Time.now + 78191284000
=> 2306-10-12 10:25:22 -0700

@mkristian mkristian reopened this Jul 2, 2014
@joevandyk joevandyk reopened this Jul 2, 2014
@mkristian
Copy link
Member

sorry - did not use big enough numbers to add ;)

@joevandyk
Copy link
Author

I was using the smallest number possible that would show the overflow. Looks like JRuby 1.7.5, instead of overflowing and going negative, just reaches the max date and stops.

@joevandyk
Copy link
Author

https://jira.codehaus.org/browse/JRUBY-7095 looks related.

@enebo enebo modified the milestones: JRuby 1.7.14, JRuby 1.7.15 Aug 27, 2014
@rtyler
Copy link

rtyler commented Aug 7, 2015

I believe @joevandyk's analysis is correct and makes this bug still valid against JRuby 9.0.0.0

On MRI Time.now + 78191284000 goes to the year 4493 whereas on my 9k/JDK8 install it goes to the year 2307.

That ain't right

@rtyler rtyler added the core label Aug 7, 2015
@rtyler rtyler removed this from the JRuby 1.7.15 milestone Aug 7, 2015
MSNexploder added a commit to MSNexploder/jruby that referenced this issue Jun 5, 2017
MSNexploder added a commit to MSNexploder/jruby that referenced this issue Jun 5, 2017
@headius headius closed this as completed in 1ca3575 Jun 5, 2017
headius added a commit that referenced this issue Jun 5, 2017
try harder to avoid long overflow in Time#+ (fixes #1779)
@joevandyk
Copy link
Author

thanks @headius !

@kares kares added this to the JRuby 9.1.11.0 milestone Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants