ruby-changes:8806
From: shugo <ko1@a...>
Date: Mon, 24 Nov 2008 23:29:52 +0900 (JST)
Subject: [ruby-changes:8806] Ruby:r20342 (trunk): * strftime.c (rb_strftime): The # flag should work with %a, %A, %b,
shugo 2008-11-24 23:29:37 +0900 (Mon, 24 Nov 2008) New Revision: 20342 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20342 Log: * strftime.c (rb_strftime): The # flag should work with %a, %A, %b, %B, and %h. [ruby-dev:37162] * test/ruby/test_time.rb (test_strftime): ditto. Modified files: trunk/ChangeLog trunk/strftime.c trunk/test/ruby/test_time.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 20341) +++ ChangeLog (revision 20342) @@ -1,3 +1,10 @@ +Mon Nov 24 23:27:28 2008 Shugo Maeda <shugo@r...> + + * strftime.c (rb_strftime): The # flag should work with %a, %A, %b, + %B, and %h. [ruby-dev:37162] + + * test/ruby/test_time.rb (test_strftime): ditto. + Mon Nov 24 23:16:32 2008 Yukihiro Matsumoto <matz@r...> * signal.c (register_sigaltstack): should not add external Index: strftime.c =================================================================== --- strftime.c (revision 20341) +++ strftime.c (revision 20342) @@ -318,6 +318,10 @@ continue; case 'a': /* abbreviated weekday name */ + if (flags & BIT_OF(CHCASE)) { + flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE)); + flags |= BIT_OF(UPPER); + } if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6) i = 1, tp = "?"; else @@ -325,6 +329,10 @@ break; case 'A': /* full weekday name */ + if (flags & BIT_OF(CHCASE)) { + flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE)); + flags |= BIT_OF(UPPER); + } if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6) i = 1, tp = "?"; else @@ -335,6 +343,10 @@ case 'h': /* abbreviated month name */ #endif case 'b': /* abbreviated month name */ + if (flags & BIT_OF(CHCASE)) { + flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE)); + flags |= BIT_OF(UPPER); + } if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11) i = 1, tp = "?"; else @@ -342,6 +354,10 @@ break; case 'B': /* full month name */ + if (flags & BIT_OF(CHCASE)) { + flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE)); + flags |= BIT_OF(UPPER); + } if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11) i = 1, tp = "?"; else Index: test/ruby/test_time.rb =================================================================== --- test/ruby/test_time.rb (revision 20341) +++ test/ruby/test_time.rb (revision 20342) @@ -461,5 +461,12 @@ assert_equal("\n", T2000.strftime("%1n")) assert_equal(" \n", T2000.strftime("%3n")) assert_equal("00\n", T2000.strftime("%03n")) + + # [ruby-dev:37162] + assert_equal("SAT", T2000.strftime("%#a")) + assert_equal("SATURDAY", T2000.strftime("%#A")) + assert_equal("JAN", T2000.strftime("%#b")) + assert_equal("JANUARY", T2000.strftime("%#B")) + assert_equal("JAN", T2000.strftime("%#h")) end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/