Project

General

Profile

Feature #9794 ยป 0001-datetime-fix-strptime-s-z.patch

Fix - felipec (Felipe Contreras), 05/02/2014 10:20 AM

View differences:

ext/date/date_core.c
static VALUE
rt_rewrite_frags(VALUE hash)
{
VALUE seconds;
VALUE seconds, offset;
seconds = ref_hash("seconds");
if (!NIL_P(seconds)) {
VALUE d, h, min, s, fr;
offset = ref_hash("offset");
if(!NIL_P(offset)) {
seconds = f_add(seconds, offset);
}
d = f_idiv(seconds, INT2FIX(DAY_IN_SECONDS));
fr = f_mod(seconds, INT2FIX(DAY_IN_SECONDS));
......
set_hash("sec", s);
set_hash("sec_fraction", fr);
del_hash("seconds");
del_hash("offset");
}
return hash;
}
test/date/test_date_strptime.rb
DateTime.strptime('2002-03-14T11:22:33-09:00', '%FT%T%Z'))
assert_equal(DateTime.new(2002,3,14,11,22,33, -9.to_r/24) + 123456789.to_r/1000000000/86400,
DateTime.strptime('2002-03-14T11:22:33.123456789-09:00', '%FT%T.%N%Z'))
assert_equal(Rational(1, 24), DateTime.strptime('0 +0100', '%s %z').offset)
end
def test_strptime__2
    (1-1/1)