ruby-changes:23348
From: nobu <ko1@a...>
Date: Thu, 19 Apr 2012 16:34:06 +0900 (JST)
Subject: [ruby-changes:23348] nobu:r35399 (trunk): * strftime.c (rb_strftime_with_timespec): fix carrir-up bug and
nobu 2012-04-19 16:33:55 +0900 (Thu, 19 Apr 2012) New Revision: 35399 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35399 Log: * strftime.c (rb_strftime_with_timespec): fix carrir-up bug and overwrite '+' with '-' if negative offset less than a hour. [ruby-core:44447][Bug #6323] Modified files: trunk/ChangeLog trunk/strftime.c trunk/test/ruby/test_time.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 35398) +++ ChangeLog (revision 35399) @@ -1,3 +1,9 @@ +Thu Apr 19 16:33:53 2012 Nobuyoshi Nakada <nobu@r...> + + * strftime.c (rb_strftime_with_timespec): fix carrir-up bug and + overwrite '+' with '-' if negative offset less than a hour. + [ruby-core:44447][Bug #6323] + Thu Apr 19 09:39:57 2012 Nobuyoshi Nakada <nobu@r...> * ext/-test-/win32/dln/extconf.rb: need import library for ordinal Index: strftime.c =================================================================== --- strftime.c (revision 35398) +++ strftime.c (revision 35399) @@ -493,9 +493,12 @@ sign = +1; } i = snprintf(s, endp - s, (padding == ' ' ? "%+*ld" : "%+.*ld"), - precision + 2, sign * (off / 360 + 1)); + precision + 1, sign * (off / 3600)); if (i < 0) goto err; - s += i - 1; + if (sign < 0 && off < 3600) { + *(padding == ' ' ? s + i - 2 : s) = '-'; + } + s += i; off = off % 3600; if (1 <= colons) *s++ = ':'; Index: test/ruby/test_time.rb =================================================================== --- test/ruby/test_time.rb (revision 35398) +++ test/ruby/test_time.rb (revision 35399) @@ -684,6 +684,22 @@ assert_equal("-000005:00", t.strftime("%:10z"), bug4458) assert_equal(" -5:00:00", t.strftime("%_::10z"), bug4458) assert_equal("-005:00:00", t.strftime("%::10z"), bug4458) + + bug6323 = '[ruby-core:44447]' + t = T2000.getlocal("+00:36") + assert_equal(" +036", t.strftime("%_10z"), bug6323) + assert_equal("+000000036", t.strftime("%10z"), bug6323) + assert_equal(" +0:36", t.strftime("%_:10z"), bug6323) + assert_equal("+000000:36", t.strftime("%:10z"), bug6323) + assert_equal(" +0:36:00", t.strftime("%_::10z"), bug6323) + assert_equal("+000:36:00", t.strftime("%::10z"), bug6323) + t = T2000.getlocal("-00:55") + assert_equal(" -055", t.strftime("%_10z"), bug6323) + assert_equal("-000000055", t.strftime("%10z"), bug6323) + assert_equal(" -0:55", t.strftime("%_:10z"), bug6323) + assert_equal("-000000:55", t.strftime("%:10z"), bug6323) + assert_equal(" -0:55:00", t.strftime("%_::10z"), bug6323) + assert_equal("-000:55:00", t.strftime("%::10z"), bug6323) end def test_delegate -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/