Skip to content

Commit 2dc0381

Browse files
byrootmame
authored andcommitted
check_limit: also handle symbols
1 parent 88ac362 commit 2dc0381

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ext/date/date_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4343,6 +4343,7 @@ static void
43434343
check_limit(VALUE str, VALUE opt)
43444344
{
43454345
if (NIL_P(str)) return;
4346+
if (SYMBOL_P(str)) str = rb_sym2str(str);
43464347

43474348
StringValue(str);
43484349
size_t slen = RSTRING_LEN(str);

test/date/test_date_parse.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,10 @@ def test__iso8601
851851

852852
h = Date._iso8601(nil)
853853
assert_equal({}, h)
854+
855+
h = Date._iso8601('01-02-03T04:05:06Z'.to_sym)
856+
assert_equal([2001, 2, 3, 4, 5, 6, 0],
857+
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
854858
end
855859

856860
def test__rfc3339
@@ -869,6 +873,10 @@ def test__rfc3339
869873

870874
h = Date._rfc3339(nil)
871875
assert_equal({}, h)
876+
877+
h = Date._rfc3339('2001-02-03T04:05:06Z'.to_sym)
878+
assert_equal([2001, 2, 3, 4, 5, 6, 0],
879+
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
872880
end
873881

874882
def test__xmlschema
@@ -954,6 +962,10 @@ def test__xmlschema
954962

955963
h = Date._xmlschema(nil)
956964
assert_equal({}, h)
965+
966+
h = Date._xmlschema('2001-02-03'.to_sym)
967+
assert_equal([2001, 2, 3, nil, nil, nil, nil],
968+
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
957969
end
958970

959971
def test__rfc2822
@@ -989,6 +1001,10 @@ def test__rfc2822
9891001

9901002
h = Date._rfc2822(nil)
9911003
assert_equal({}, h)
1004+
1005+
h = Date._rfc2822('Sat, 3 Feb 2001 04:05:06 UT'.to_sym)
1006+
assert_equal([2001, 2, 3, 4, 5, 6, 0],
1007+
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
9921008
end
9931009

9941010
def test__httpdate
@@ -1012,6 +1028,10 @@ def test__httpdate
10121028

10131029
h = Date._httpdate(nil)
10141030
assert_equal({}, h)
1031+
1032+
h = Date._httpdate('Sat, 03 Feb 2001 04:05:06 GMT'.to_sym)
1033+
assert_equal([2001, 2, 3, 4, 5, 6, 0],
1034+
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
10151035
end
10161036

10171037
def test__jisx0301
@@ -1091,6 +1111,10 @@ def test__jisx0301
10911111

10921112
h = Date._jisx0301(nil)
10931113
assert_equal({}, h)
1114+
1115+
h = Date._jisx0301('H13.02.03T04:05:06.07+0100'.to_sym)
1116+
assert_equal([2001, 2, 3, 4, 5, 6, 3600],
1117+
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
10941118
end
10951119

10961120
def test_iso8601

0 commit comments

Comments
 (0)