diff options
Diffstat (limited to 'test/date/test_date_parse.rb')
-rw-r--r-- | test/date/test_date_parse.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/date/test_date_parse.rb b/test/date/test_date_parse.rb index 5bc2cebf82..d1163b29cb 100644 --- a/test/date/test_date_parse.rb +++ b/test/date/test_date_parse.rb @@ -1020,6 +1020,15 @@ class TestDateParse < Test::Unit::TestCase h = Date._jisx0301('S63.02.03') assert_equal([1988, 2, 3, nil, nil, nil, nil], h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.04.30') + assert_equal([2019, 4, 30, nil, nil, nil, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.05.01') + assert_equal([2019, 5, 1, nil, nil, nil, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('R01.05.01') + assert_equal([2019, 5, 1, nil, nil, nil, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) h = Date._jisx0301('H13.02.03T04:05:06') assert_equal([2001, 2, 3, 4, 5, 6, nil], @@ -1034,6 +1043,45 @@ class TestDateParse < Test::Unit::TestCase assert_equal([2001, 2, 3, 4, 5, 6, 3600], h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.04.30T04:05:06') + assert_equal([2019, 4, 30, 4, 5, 6, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.04.30T04:05:06,07') + assert_equal([2019, 4, 30, 4, 5, 6, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.04.30T04:05:06Z') + assert_equal([2019, 4, 30, 4, 5, 6, 0], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.04.30T04:05:06.07+0100') + assert_equal([2019, 4, 30, 4, 5, 6, 3600], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + + h = Date._jisx0301('H31.05.01T04:05:06') + assert_equal([2019, 5, 1, 4, 5, 6, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.05.01T04:05:06,07') + assert_equal([2019, 5, 1, 4, 5, 6, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.05.01T04:05:06Z') + assert_equal([2019, 5, 1, 4, 5, 6, 0], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('H31.05.01T04:05:06.07+0100') + assert_equal([2019, 5, 1, 4, 5, 6, 3600], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + + h = Date._jisx0301('R01.05.01T04:05:06') + assert_equal([2019, 5, 1, 4, 5, 6, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('R01.05.01T04:05:06,07') + assert_equal([2019, 5, 1, 4, 5, 6, nil], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('R01.05.01T04:05:06Z') + assert_equal([2019, 5, 1, 4, 5, 6, 0], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('R01.05.01T04:05:06.07+0100') + assert_equal([2019, 5, 1, 4, 5, 6, 3600], + h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)) + h = Date._jisx0301('') assert_equal({}, h) @@ -1126,9 +1174,33 @@ class TestDateParse < Test::Unit::TestCase assert_equal(Date.new(2001,2,3), d) assert_equal(Date::ITALY + 10, d.start) + d = Date.jisx0301('H31.04.30', Date::ITALY + 10) + assert_equal(Date.new(2019,4,30), d) + assert_equal(Date::ITALY + 10, d.start) + + d = Date.jisx0301('H31.05.01', Date::ITALY + 10) + assert_equal(Date.new(2019,5,1), d) + assert_equal(Date::ITALY + 10, d.start) + + d = Date.jisx0301('R01.05.01', Date::ITALY + 10) + assert_equal(Date.new(2019,5,1), d) + assert_equal(Date::ITALY + 10, d.start) + d = DateTime.jisx0301('H13.02.03T04:05:06+07:00', Date::ITALY + 10) assert_equal(DateTime.new(2001,2,3,4,5,6,'+07:00'), d) assert_equal(Date::ITALY + 10, d.start) + + d = DateTime.jisx0301('H31.04.30T04:05:06+07:00', Date::ITALY + 10) + assert_equal(DateTime.new(2019,4,30,4,5,6,'+07:00'), d) + assert_equal(Date::ITALY + 10, d.start) + + d = DateTime.jisx0301('H31.05.01T04:05:06+07:00', Date::ITALY + 10) + assert_equal(DateTime.new(2019,5,1,4,5,6,'+07:00'), d) + assert_equal(Date::ITALY + 10, d.start) + + d = DateTime.jisx0301('R01.05.01T04:05:06+07:00', Date::ITALY + 10) + assert_equal(DateTime.new(2019,5,1,4,5,6,'+07:00'), d) + assert_equal(Date::ITALY + 10, d.start) end def test_given_string |