Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/date/date_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ m_ajd(union DateData *x)

if (simple_dat_p(x)) {
r = m_real_jd(x);
if (FIXNUM_P(r) && FIX2LONG(r) <= (FIXNUM_MAX / 2)) {
if (FIXNUM_P(r) && FIX2LONG(r) <= (FIXNUM_MAX / 2) && FIX2LONG(r) >= (FIXNUM_MIN + 1) / 2) {
long ir = FIX2LONG(r);
ir = ir * 2 - 1;
return rb_rational_new2(LONG2FIX(ir), INT2FIX(2));
Expand Down
5 changes: 5 additions & 0 deletions test/date/test_switch_hitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ def test_jd
[d.year, d.mon, d.mday, d.hour, d.min, d.sec, d.offset])
end

def test_ajd
assert_equal(Date.civil(2008, 1, 16).ajd, 4908963r/2)
assert_equal(Date.civil(-11082381539297990, 2, 19).ajd, -8095679714453739481r/2)
end

def test_ordinal
d = Date.ordinal
assert_equal([-4712, 1], [d.year, d.yday])
Expand Down