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

9.2.0.0 regression in Date#to_time for BC dates resulting in Time off by 1 year #5195

Closed
jeremyevans opened this Issue May 25, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@jeremyevans
Copy link
Contributor

jeremyevans commented May 25, 2018

Environment

Tested on:

jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.144-b01 on 1.8.0_144-b01 +jit [OpenBSD-x86_64]
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 +jit [mswin32-x86_64]

Expected Behavior

CRuby 2.3, CRuby 2.5, and JRuby 9.1 all return correct results:

$ ruby -r date -ve "d = Date.new(-1); p d; p d.to_time"
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
#<Date: -0001-01-01 ((1720693j,0s,0n),+0s,2299161j)>
-0001-01-01 00:00:00 -0800

$ ruby -r date -ve "d = Date.new(-1); p d; p d.to_time"
ruby 2.5.0p0 (2017-12-25 revision 61468) [x64-mingw32]
#<Date: -0001-01-01 ((1720693j,0s,0n),+0s,2299161j)>
-0001-01-01 00:00:00 -0800

$ jruby -r date -ve "d = Date.new(-1); p d; p d.to_time"
jruby 9.1.12.0 (2.3.3) 2017-06-15 33c6439 Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 +jit [mswin32-x86_64]
#<Date: -0001-01-01 ((1720693j,0s,0n),+0s,2299161j)>
-0001-01-01 00:00:00 -0752

Actual Behavior

JRuby 9.2 has the Time value wrong:

$ jruby -r date -ve "d = Date.new(-1); p d; p d.to_time"
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 +jit [mswin32-x86_64]
#<Date: -0001-01-01 ((1720693j,0s,0n),+0s,2299161j)>
-0002-01-01 00:00:00 -0752

While not shown here, this also affects DateTime#to_time, which I'm guessing uses the same implementation.

Also note that both JRuby versions have a different timezone offset compared to MRI, but I'm not sure if that is a bug or just the result of using different timezone settings between Java and C.

I thought this may be related to #5191, but looking at the fix for that, I think it may be a different issue. However, I did not check the master branch to see if this has already been fixed.

@kares kares self-assigned this May 27, 2018

@kares

This comment has been minimized.

Copy link
Member

kares commented May 27, 2018

thanks - as you guessed ... should be the same cause as in #5191 (but seems it isn't)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.