Skip to content

9.2.0.0 Regression in DateTime.parse for BC dates #5191

@jeremyevans

Description

@jeremyevans

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)>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions