Skip to content

Commit

Permalink
[fix] Date civil impl (jd calc) should not adjust year (due joda)
Browse files Browse the repository at this point in the history
resolves #5191
  • Loading branch information
kares committed May 25, 2018
1 parent 98abdb4 commit 48b4291
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ext/date/RubyDate.java
Expand Up @@ -482,7 +482,7 @@ public static IRubyObject valid_civil_p(ThreadContext context, IRubyObject self,
}

static Long validCivilImpl(IRubyObject year, IRubyObject month, IRubyObject day, final long sg) {
final int y = (sg > 0) ? getYear(year) : year.convertToInteger().getIntValue();
final int y = year.convertToInteger().getIntValue();
final int m = getMonth(month);
final int d = day.convertToInteger().getIntValue();

Expand Down
6 changes: 6 additions & 0 deletions test/jruby/test_date.rb
Expand Up @@ -781,4 +781,10 @@ def test_civil_sec_fraction
assert_equal 3r/100_000, dt.send(:sec_fraction)
end

def test_parse_bc_date_time # GH-5191
dt = DateTime.parse('1200-02-15 14:13:20-00:00:00 BC')
assert_equal '#<DateTime: -1199-02-15T14:13:20+00:00 ((1283169j,51200s,0n),+0s,2299161j)>', dt.inspect
assert_equal -1199, dt.year
end

end

0 comments on commit 48b4291

Please sign in to comment.