[ruby/date] Date._<format>(nil)
should return an empty Hash
Fix: https://github.com/ruby/date/issues/39
This is how versions previous to 3.2.1 behaved and Active Support
currently rely on this behavior.
90357af080/activesupport/lib/active_support/values/time_zone.rb (L383-L384)
Any Rails application upgrading to date `3.2.1` might run into unexpected errors.
https://github.com/ruby/date/commit/8f2d7a0c7e
This commit is contained in:
parent
17e64cca6b
commit
fa674cf723
@ -4342,6 +4342,8 @@ get_limit(VALUE opt)
|
|||||||
static void
|
static void
|
||||||
check_limit(VALUE str, VALUE opt)
|
check_limit(VALUE str, VALUE opt)
|
||||||
{
|
{
|
||||||
|
if (NIL_P(str)) return;
|
||||||
|
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
size_t slen = RSTRING_LEN(str);
|
size_t slen = RSTRING_LEN(str);
|
||||||
size_t limit = get_limit(opt);
|
size_t limit = get_limit(opt);
|
||||||
|
@ -848,6 +848,9 @@ class TestDateParse < Test::Unit::TestCase
|
|||||||
|
|
||||||
h = Date._iso8601('')
|
h = Date._iso8601('')
|
||||||
assert_equal({}, h)
|
assert_equal({}, h)
|
||||||
|
|
||||||
|
h = Date._iso8601(nil)
|
||||||
|
assert_equal({}, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test__rfc3339
|
def test__rfc3339
|
||||||
@ -863,6 +866,9 @@ class TestDateParse < Test::Unit::TestCase
|
|||||||
|
|
||||||
h = Date._rfc3339('')
|
h = Date._rfc3339('')
|
||||||
assert_equal({}, h)
|
assert_equal({}, h)
|
||||||
|
|
||||||
|
h = Date._rfc3339(nil)
|
||||||
|
assert_equal({}, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test__xmlschema
|
def test__xmlschema
|
||||||
@ -945,6 +951,9 @@ class TestDateParse < Test::Unit::TestCase
|
|||||||
|
|
||||||
h = Date._xmlschema('')
|
h = Date._xmlschema('')
|
||||||
assert_equal({}, h)
|
assert_equal({}, h)
|
||||||
|
|
||||||
|
h = Date._xmlschema(nil)
|
||||||
|
assert_equal({}, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test__rfc2822
|
def test__rfc2822
|
||||||
@ -977,6 +986,9 @@ class TestDateParse < Test::Unit::TestCase
|
|||||||
|
|
||||||
h = Date._rfc2822('')
|
h = Date._rfc2822('')
|
||||||
assert_equal({}, h)
|
assert_equal({}, h)
|
||||||
|
|
||||||
|
h = Date._rfc2822(nil)
|
||||||
|
assert_equal({}, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test__httpdate
|
def test__httpdate
|
||||||
@ -997,6 +1009,9 @@ class TestDateParse < Test::Unit::TestCase
|
|||||||
|
|
||||||
h = Date._httpdate('')
|
h = Date._httpdate('')
|
||||||
assert_equal({}, h)
|
assert_equal({}, h)
|
||||||
|
|
||||||
|
h = Date._httpdate(nil)
|
||||||
|
assert_equal({}, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test__jisx0301
|
def test__jisx0301
|
||||||
@ -1073,6 +1088,9 @@ class TestDateParse < Test::Unit::TestCase
|
|||||||
|
|
||||||
h = Date._jisx0301('')
|
h = Date._jisx0301('')
|
||||||
assert_equal({}, h)
|
assert_equal({}, h)
|
||||||
|
|
||||||
|
h = Date._jisx0301(nil)
|
||||||
|
assert_equal({}, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_iso8601
|
def test_iso8601
|
||||||
|
Loading…
x
Reference in New Issue
Block a user