Project

General

Profile

Bug #5908 ยป datemutate.patch

tenderlovemaking (Aaron Patterson), 01/19/2012 04:21 AM

View differences:

ext/date/date_parse.c
rb_match_busy(backref);
hash = rb_hash_new();
str = rb_str_dup(str);
if (xmlschema_datetime(str, hash))
goto ok;
......
rb_match_busy(backref);
hash = rb_hash_new();
str = rb_str_dup(str);
rfc2822(str, hash);
rb_backref_set(backref);
return hash;
......
rb_match_busy(backref);
hash = rb_hash_new();
str = rb_str_dup(str);
if (httpdate_type1(str, hash))
goto ok;
test/date/test_date_parse.rb
assert_equal(Date::ITALY + 10, d.start)
end
def test_date_xmlschema_does_not_mutate
x = "2006-02-13T10:37:00.000-05:00"
y = x.dup
Date.xmlschema x
assert_equal y, x
end
def test_datetime_xmlschema_does_not_mutate
x = "2006-02-13T10:37:00.000-05:00"
y = x.dup
DateTime.xmlschema x
assert_equal y, x
end
def test_rfc2822
assert_instance_of(Date, Date.rfc2822)
assert_instance_of(DateTime, DateTime.rfc2822)
......
assert_equal(Date::ITALY + 10, d.start)
end
def test_rfc2822_does_not_mutate
x = 'Mon, 1 Jan -4712 00:00:00 +0000'
y = x.dup
Date.rfc2822 x
assert_equal y, x
DateTime.rfc2822 x
assert_equal y, x
end
def test_httpdate
assert_instance_of(Date, Date.httpdate)
assert_instance_of(DateTime, DateTime.httpdate)
......
assert_equal(Date::ITALY + 10, d.start)
end
def test_httpdate_does_not_mutate
x = "Mon, 01 Jan -4712 00:00:00 GMT"
y = x.dup
Date.httpdate x
assert_equal y, x
DateTime.httpdate x
assert_equal y, x
end
def test_jisx0301
assert_instance_of(Date, Date.jisx0301)
assert_instance_of(DateTime, DateTime.jisx0301)
    (1-1/1)