From a5d37d10a9e18952badcf821679104613590e779 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 7 Jul 2010 21:07:01 +0000 Subject: * strftime.c (rb_strftime_with_timespec): support %:z and %::z. [ruby-dev:41841] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_time_tz.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb index 1041e31d2b..4942d32028 100644 --- a/test/ruby/test_time_tz.rb +++ b/test/ruby/test_time_tz.rb @@ -18,7 +18,7 @@ class TestTimeTZ < Test::Unit::TestCase end module Util - def format_gmtoff(gmtoff) + def format_gmtoff(gmtoff, colon=false) if gmtoff < 0 expected = "-" gmtoff = -gmtoff @@ -26,7 +26,20 @@ class TestTimeTZ < Test::Unit::TestCase expected = "+" end gmtoff /= 60 - expected << "%02d%02d" % [gmtoff / 60, gmtoff % 60] + expected << "%02d" % [gmtoff / 60] + expected << ":" if colon + expected << "%02d" % [gmtoff % 60] + expected + end + + def format_gmtoff2(gmtoff) + if gmtoff < 0 + expected = "-" + gmtoff = -gmtoff + else + expected = "+" + end + expected << "%02d:%02d:%02d" % [gmtoff / 3600, gmtoff % 3600 / 60, gmtoff % 60] expected end @@ -189,6 +202,9 @@ class TestTimeTZ < Test::Unit::TestCase assert_nothing_raised(mesg) { t.localtime } assert_equal(expected, time_to_s(t), mesg) assert_equal(gmtoff, t.gmtoff) + assert_equal(format_gmtoff(gmtoff), t.strftime("%z")) + assert_equal(format_gmtoff(gmtoff, true), t.strftime("%:z")) + assert_equal(format_gmtoff2(gmtoff), t.strftime("%::z")) } } } @@ -289,6 +305,7 @@ right/America/Los_Angeles Wed Dec 31 23:59:60 2008 UTC = Wed Dec 31 15:59:60 20 #right/Asia/Tokyo Sat Dec 31 23:59:60 2005 UTC = Sun Jan 1 08:59:60 2006 JST isdst=0 gmtoff=32400 right/Europe/Paris Fri Jun 30 23:59:60 1972 UTC = Sat Jul 1 00:59:60 1972 CET isdst=0 gmtoff=3600 right/Europe/Paris Wed Dec 31 23:59:60 2008 UTC = Thu Jan 1 00:59:60 2009 CET isdst=0 gmtoff=3600 +Europe/Lisbon Mon Jan 1 00:36:31 1912 UTC = Sun Dec 31 23:59:59 1911 LMT isdst=0 gmtoff=-2192 End gen_zdump_test end -- cgit v1.2.3