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 DateTime.parse for BC dates #5191

Closed
jeremyevans opened this issue May 24, 2018 · 1 comment
Closed

9.2.0.0 Regression in DateTime.parse for BC dates #5191

jeremyevans opened this issue May 24, 2018 · 1 comment
Assignees
Milestone

Comments

@jeremyevans
Copy link
Contributor

Environment

Tested on both:

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

DateTime.parse for BC dates does not match CRuby behavior, it is off by 1 year. CRuby 2.3, CRuby 2.5, and JRuby 9.1 return the correct value, since 1 BC is year 0:

$ ruby -v -r date -e "p DateTime.parse('1200-02-15 14:13:20-00:00:00 BC')"
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
#<DateTime: -1199-02-15T14:13:20+00:00 ((1283169j,51200s,0n),+0s,2299161j)>

$ ruby -v -r date -e "p DateTime.parse('1200-02-15 14:13:20-00:00:00 BC')"
ruby 2.5.0p0 (2017-12-25 revision 61468) [x64-mingw32]
#<DateTime: -1199-02-15T14:13:20+00:00 ((1283169j,51200s,0n),+0s,2299161j)>

$ jruby -v -r date -e "p DateTime.parse('1200-02-15 14:13:20-00:00:00 BC')"
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]
#<DateTime: -1199-02-15T14:13:20+00:00 ((1283169j,51200s,0n),+0s,2299161j)>

Actual Behavior

JRuby 9.2.0.0 just makes the year negative:

$ jruby -v -r date -e "p DateTime.parse('1200-02-15 14:13:20-00:00:00 BC')"
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]
#<DateTime: -1200-02-15T14:13:20+00:00 ((1282803j,51200s,0n),+0s,2299161j)>
@kares
Copy link
Member

kares commented May 25, 2018

interesting, this should have been extensively covered by tests - looking

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

2 participants