[前][次][番号順一覧][スレッド一覧]

ruby-changes:8869

From: yugui <ko1@a...>
Date: Sun, 30 Nov 2008 18:23:46 +0900 (JST)
Subject: [ruby-changes:8869] Ruby:r20405 (ruby_1_9_1): merges r20342 from trunk to ruby_1_9_1.

yugui	2008-11-30 18:22:13 +0900 (Sun, 30 Nov 2008)

  New Revision: 20405

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20405

  Log:
    merges r20342 from trunk to ruby_1_9_1.
    * 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:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/strftime.c
    branches/ruby_1_9_1/test/ruby/test_time.rb

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 20404)
+++ ruby_1_9_1/ChangeLog	(revision 20405)
@@ -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: ruby_1_9_1/strftime.c
===================================================================
--- ruby_1_9_1/strftime.c	(revision 20404)
+++ ruby_1_9_1/strftime.c	(revision 20405)
@@ -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: ruby_1_9_1/test/ruby/test_time.rb
===================================================================
--- ruby_1_9_1/test/ruby/test_time.rb	(revision 20404)
+++ ruby_1_9_1/test/ruby/test_time.rb	(revision 20405)
@@ -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/

[前][次][番号順一覧][スレッド一覧]