98 lines
2.8 KiB
Diff
98 lines
2.8 KiB
Diff
From a87c56f820dac90d50544ad33cc546daa9f29a9a Mon Sep 17 00:00:00 2001
|
|
From: Jean Boussier <jean.boussier@gmail.com>
|
|
Date: Tue, 16 Nov 2021 14:03:42 +0100
|
|
Subject: [PATCH] [ruby/date] check_limit: also handle symbols
|
|
|
|
https://github.com/ruby/date/commit/376c65942b
|
|
---
|
|
ext/date/date_core.c | 1 +
|
|
test/date/test_date_parse.rb | 24 ++++++++++++++++++++++++
|
|
2 files changed, 25 insertions(+)
|
|
|
|
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
|
|
index 516640b..0a9468a 100644
|
|
--- a/ext/date/date_core.c
|
|
+++ b/ext/date/date_core.c
|
|
@@ -4305,6 +4305,7 @@ static void
|
|
check_limit(VALUE str, VALUE opt)
|
|
{
|
|
if (NIL_P(str)) return;
|
|
+ if (SYMBOL_P(str)) str = rb_sym2str(str);
|
|
|
|
StringValue(str);
|
|
size_t slen = RSTRING_LEN(str);
|
|
diff --git a/test/date/test_date_parse.rb b/test/date/test_date_parse.rb
|
|
index dfc018b..5bc2ceb 100644
|
|
--- a/test/date/test_date_parse.rb
|
|
+++ b/test/date/test_date_parse.rb
|
|
@@ -827,6 +827,10 @@ class TestDateParse < Test::Unit::TestCase
|
|
|
|
h = Date._iso8601(nil)
|
|
assert_equal({}, h)
|
|
+
|
|
+ h = Date._iso8601('01-02-03T04:05:06Z'.to_sym)
|
|
+ assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
|
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
|
end
|
|
|
|
def test__rfc3339
|
|
@@ -845,6 +849,10 @@ class TestDateParse < Test::Unit::TestCase
|
|
|
|
h = Date._rfc3339(nil)
|
|
assert_equal({}, h)
|
|
+
|
|
+ h = Date._rfc3339('2001-02-03T04:05:06Z'.to_sym)
|
|
+ assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
|
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
|
end
|
|
|
|
def test__xmlschema
|
|
@@ -930,6 +938,10 @@ class TestDateParse < Test::Unit::TestCase
|
|
|
|
h = Date._xmlschema(nil)
|
|
assert_equal({}, h)
|
|
+
|
|
+ h = Date._xmlschema('2001-02-03'.to_sym)
|
|
+ assert_equal([2001, 2, 3, nil, nil, nil, nil],
|
|
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
|
end
|
|
|
|
def test__rfc2822
|
|
@@ -965,6 +977,10 @@ class TestDateParse < Test::Unit::TestCase
|
|
|
|
h = Date._rfc2822(nil)
|
|
assert_equal({}, h)
|
|
+
|
|
+ h = Date._rfc2822('Sat, 3 Feb 2001 04:05:06 UT'.to_sym)
|
|
+ assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
|
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
|
end
|
|
|
|
def test__httpdate
|
|
@@ -988,6 +1004,10 @@ class TestDateParse < Test::Unit::TestCase
|
|
|
|
h = Date._httpdate(nil)
|
|
assert_equal({}, h)
|
|
+
|
|
+ h = Date._httpdate('Sat, 03 Feb 2001 04:05:06 GMT'.to_sym)
|
|
+ assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
|
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
|
end
|
|
|
|
def test__jisx0301
|
|
@@ -1019,6 +1039,10 @@ class TestDateParse < Test::Unit::TestCase
|
|
|
|
h = Date._jisx0301(nil)
|
|
assert_equal({}, h)
|
|
+
|
|
+ h = Date._jisx0301('H13.02.03T04:05:06.07+0100'.to_sym)
|
|
+ assert_equal([2001, 2, 3, 4, 5, 6, 3600],
|
|
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
|
end
|
|
|
|
def test_iso8601
|
|
--
|
|
2.33.0
|
|
|
|
|