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
1 change: 1 addition & 0 deletions ext/date/date_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3369,6 +3369,7 @@ old_to_new(VALUE ajd, VALUE of, VALUE sg,

if (f_lt_p(*rsf, INT2FIX(0)) ||
f_ge_p(*rsf, INT2FIX(SECOND_IN_NANOSECONDS)))
rb_raise(eDateError, "invalid second fraction");

if (*rof < -DAY_IN_SECONDS || *rof > DAY_IN_SECONDS) {
*rof = 0;
Expand Down
22 changes: 22 additions & 0 deletions test/date/test_date_marshal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ def test_marshal_nth
assert_equal(Date.new(-123456,7,8), Marshal.load(s))
end

def test_marshal_load_old_format_offset
d = DateTime.allocate
d.marshal_load([Rational(0), Rational(1, 24), Date::ITALY])
assert_equal(Rational(1, 24), d.offset)

d = DateTime.allocate
d.marshal_load([Rational(0), 1, Date::ITALY])
assert_equal(1, d.offset)

d = DateTime.allocate
assert_warning(/invalid offset/) do
d.marshal_load([Rational(0), 5, Date::ITALY])
end
assert_equal(0, d.offset)

d = DateTime.allocate
assert_warning(/invalid offset/) do
d.marshal_load([Rational(0), -5, Date::ITALY])
end
assert_equal(0, d.offset)
end

def test_memsize
require 'objspace'
t = DateTime.new(2018, 11, 13)
Expand Down
Loading