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

@joevandyk joevandyk commented Jul 1, 2014

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

@mkristian mkristian commented Jul 2, 2014

???

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

@joevandyk joevandyk commented Jul 2, 2014

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

@mkristian mkristian commented Jul 2, 2014

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.

@mkristian mkristian closed this Jul 2, 2014
@joevandyk
Copy link
Author

@joevandyk joevandyk commented Jul 2, 2014

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 closed this Jul 2, 2014
@joevandyk joevandyk reopened this Jul 2, 2014
@mkristian
Copy link
Member

@mkristian mkristian commented Jul 2, 2014

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

@joevandyk
Copy link
Author

@joevandyk joevandyk commented Jul 2, 2014

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

@joevandyk joevandyk commented Jul 2, 2014

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

@rtyler 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 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

@joevandyk joevandyk commented Jun 5, 2017

thanks @headius !

@kares kares added this to the JRuby 9.1.11.0 milestone Jun 5, 2017
@anubhav8421 anubhav8421 mentioned this issue Jan 27, 2019
113 of 136 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants