summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-02-27 13:46:28 +0900
committernagachika <nagachika@ruby-lang.org>2021-02-27 13:46:28 +0900
commit190ffd8761bec206582095028e5752ae5ccd7587 (patch)
tree2f42be4a14e0a22039781d1d961befac5a01d254 /test/ruby
parent931815bfd86df603337194f3fcefb46bfe3e7940 (diff)
merge revision(s) f4be7a510eebbe6507ba41d138d7d252f4a68e90,9441f3f97087a4325ee80911859d37da41fa5050: [Backport #17504]
Added tests for Time#getlocal with UTC offset --- test/ruby/test_time.rb | 8 ++++++++ 1 file changed, 8 insertions(+) Allow UTC offset without colons per ISO-8601 [Bug #17504] --- test/ruby/test_time.rb | 6 ++++++ time.c | 44 +++++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 15 deletions(-)
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_time.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index ad8fe6c8cd..1749d92a17 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -1194,6 +1194,20 @@ class TestTime < Test::Unit::TestCase
}
end
+ def test_getlocal_utc_offset
+ t = Time.gm(2000)
+ assert_equal [00, 30, 21, 31, 12, 1999], t.getlocal("-02:30").to_a[0, 6]
+ assert_equal [00, 00, 9, 1, 1, 2000], t.getlocal("+09:00").to_a[0, 6]
+ assert_equal [20, 29, 21, 31, 12, 1999], t.getlocal("-02:30:40").to_a[0, 6]
+ assert_equal [35, 10, 9, 1, 1, 2000], t.getlocal("+09:10:35").to_a[0, 6]
+ assert_equal [00, 30, 21, 31, 12, 1999], t.getlocal("-0230").to_a[0, 6]
+ assert_equal [00, 00, 9, 1, 1, 2000], t.getlocal("+0900").to_a[0, 6]
+ assert_equal [20, 29, 21, 31, 12, 1999], t.getlocal("-023040").to_a[0, 6]
+ assert_equal [35, 10, 9, 1, 1, 2000], t.getlocal("+091035").to_a[0, 6]
+ assert_raise(ArgumentError) {t.getlocal("-02:3040")}
+ assert_raise(ArgumentError) {t.getlocal("+0910:35")}
+ end
+
def test_getlocal_nil
now = Time.now
now2 = nil