aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-07 07:03:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-07 07:03:23 +0000
commit8371a9a4ceea32f8e76f3d867722b42e5477fba1 (patch)
tree60b5cb478a171209fbd859440d75a5ec5851ce05 /test
parent4f9ab3a01a475f5236632575fa4d3a6b6aef7d15 (diff)
downloadruby-8371a9a4ceea32f8e76f3d867722b42e5477fba1.tar.gz
time.c: support military time zone names
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_time_tz.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index ec5c9a2dbe..f0803d2742 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -260,6 +260,60 @@ class TestTimeTZ < Test::Unit::TestCase
assert_predicate(Time.new(2019, 1, 1, 0, 0, 0, "Z"), :utc?)
end
+ def test_military_names
+ assert_equal( +1*3600, Time.new(2019, 1, 1, 0, 0, 0, "A").gmtoff)
+ assert_equal( +2*3600, Time.new(2019, 1, 1, 0, 0, 0, "B").gmtoff)
+ assert_equal( +3*3600, Time.new(2019, 1, 1, 0, 0, 0, "C").gmtoff)
+ assert_equal( +4*3600, Time.new(2019, 1, 1, 0, 0, 0, "D").gmtoff)
+ assert_equal( +5*3600, Time.new(2019, 1, 1, 0, 0, 0, "E").gmtoff)
+ assert_equal( +6*3600, Time.new(2019, 1, 1, 0, 0, 0, "F").gmtoff)
+ assert_equal( +7*3600, Time.new(2019, 1, 1, 0, 0, 0, "G").gmtoff)
+ assert_equal( +8*3600, Time.new(2019, 1, 1, 0, 0, 0, "H").gmtoff)
+ assert_equal( +9*3600, Time.new(2019, 1, 1, 0, 0, 0, "I").gmtoff)
+ assert_equal(+10*3600, Time.new(2019, 1, 1, 0, 0, 0, "K").gmtoff)
+ assert_equal(+11*3600, Time.new(2019, 1, 1, 0, 0, 0, "L").gmtoff)
+ assert_equal(+12*3600, Time.new(2019, 1, 1, 0, 0, 0, "M").gmtoff)
+ assert_equal( -1*3600, Time.new(2019, 1, 1, 0, 0, 0, "N").gmtoff)
+ assert_equal( -2*3600, Time.new(2019, 1, 1, 0, 0, 0, "O").gmtoff)
+ assert_equal( -3*3600, Time.new(2019, 1, 1, 0, 0, 0, "P").gmtoff)
+ assert_equal( -4*3600, Time.new(2019, 1, 1, 0, 0, 0, "Q").gmtoff)
+ assert_equal( -5*3600, Time.new(2019, 1, 1, 0, 0, 0, "R").gmtoff)
+ assert_equal( -6*3600, Time.new(2019, 1, 1, 0, 0, 0, "S").gmtoff)
+ assert_equal( -7*3600, Time.new(2019, 1, 1, 0, 0, 0, "T").gmtoff)
+ assert_equal( -8*3600, Time.new(2019, 1, 1, 0, 0, 0, "U").gmtoff)
+ assert_equal( -9*3600, Time.new(2019, 1, 1, 0, 0, 0, "V").gmtoff)
+ assert_equal(-10*3600, Time.new(2019, 1, 1, 0, 0, 0, "W").gmtoff)
+ assert_equal(-11*3600, Time.new(2019, 1, 1, 0, 0, 0, "X").gmtoff)
+ assert_equal(-12*3600, Time.new(2019, 1, 1, 0, 0, 0, "Y").gmtoff)
+ assert_equal( 0, Time.new(2019, 1, 1, 0, 0, 0, "Z").gmtoff)
+
+ assert_equal( +1*3600, Time.at(0, in: "A").gmtoff)
+ assert_equal( +2*3600, Time.at(0, in: "B").gmtoff)
+ assert_equal( +3*3600, Time.at(0, in: "C").gmtoff)
+ assert_equal( +4*3600, Time.at(0, in: "D").gmtoff)
+ assert_equal( +5*3600, Time.at(0, in: "E").gmtoff)
+ assert_equal( +6*3600, Time.at(0, in: "F").gmtoff)
+ assert_equal( +7*3600, Time.at(0, in: "G").gmtoff)
+ assert_equal( +8*3600, Time.at(0, in: "H").gmtoff)
+ assert_equal( +9*3600, Time.at(0, in: "I").gmtoff)
+ assert_equal(+10*3600, Time.at(0, in: "K").gmtoff)
+ assert_equal(+11*3600, Time.at(0, in: "L").gmtoff)
+ assert_equal(+12*3600, Time.at(0, in: "M").gmtoff)
+ assert_equal( -1*3600, Time.at(0, in: "N").gmtoff)
+ assert_equal( -2*3600, Time.at(0, in: "O").gmtoff)
+ assert_equal( -3*3600, Time.at(0, in: "P").gmtoff)
+ assert_equal( -4*3600, Time.at(0, in: "Q").gmtoff)
+ assert_equal( -5*3600, Time.at(0, in: "R").gmtoff)
+ assert_equal( -6*3600, Time.at(0, in: "S").gmtoff)
+ assert_equal( -7*3600, Time.at(0, in: "T").gmtoff)
+ assert_equal( -8*3600, Time.at(0, in: "U").gmtoff)
+ assert_equal( -9*3600, Time.at(0, in: "V").gmtoff)
+ assert_equal(-10*3600, Time.at(0, in: "W").gmtoff)
+ assert_equal(-11*3600, Time.at(0, in: "X").gmtoff)
+ assert_equal(-12*3600, Time.at(0, in: "Y").gmtoff)
+ assert_equal( 0, Time.at(0, in: "Z").gmtoff)
+ end
+
MON2NUM = {
"Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6,
"Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12