Skip to content
Open
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
3 changes: 3 additions & 0 deletions ext/date/date_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3361,6 +3361,9 @@ old_to_new(VALUE ajd, VALUE of, VALUE sg,
{
VALUE jd, df, sf, of2, t;

if (RB_TYPE_P(ajd, T_FLOAT))
ajd = f_to_r(ajd);

decode_day(f_add(ajd, half_days_in_day),
&jd, &df, &sf);
t = day_to_sec(of);
Expand Down
16 changes: 16 additions & 0 deletions test/date/test_date_marshal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ def test_marshal_load_old_format_offset
assert_equal(0, d.offset)
end

def test_marshal_load_old_format_float
d = DateTime.allocate
d.marshal_load([0.25, 0, Date::ITALY])
d2 = DateTime.jd(0, 18)
assert_equal(d2, d)
assert_equal(d2.hash, d.hash)
assert_equal(d, Marshal.load(Marshal.dump(d)))

d = Date.allocate
d.marshal_load([0.5, Date::ITALY])
d2 = Date.allocate
d2.marshal_load([Rational(1, 2), Date::ITALY])
assert_equal(d2, d)
assert_equal(d2.hash, d.hash)
end

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