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

ruby-changes:23758

From: tadf <ko1@a...>
Date: Sat, 26 May 2012 18:16:37 +0900 (JST)
Subject: [ruby-changes:23758] tadf:r35809 (trunk): * ext/date/date_strftime.c: reduced the code.

tadf	2012-05-26 18:16:26 +0900 (Sat, 26 May 2012)

  New Revision: 35809

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

  Log:
    * ext/date/date_strftime.c: reduced the code.

  Modified files:
    trunk/ChangeLog
    trunk/ext/date/date_strftime.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35808)
+++ ChangeLog	(revision 35809)
@@ -1,3 +1,7 @@
+Sat May 26 18:14:57 2012  Tadayoshi Funaba  <tadf@d...>
+
+	* ext/date/date_strftime.c: reduced the code.
+
 Sat May 26 18:08:59 2012  Tadayoshi Funaba  <tadf@d...>
 
 	* time.c: modified doc.
Index: ext/date/date_strftime.c
===================================================================
--- ext/date/date_strftime.c	(revision 35808)
+++ ext/date/date_strftime.c	(revision 35809)
@@ -228,8 +228,9 @@
 	    continue;
 
 	  case 'G':	/* year of ISO week with century */
+	  case 'Y':	/* year with century */
 	    {
-		VALUE year = tmx_cwyear;
+		VALUE year = (*format == 'G') ? tmx_cwyear : tmx_year;
 		if (FIXNUM_P(year)) {
 		    long y = FIX2LONG(year);
 		    FMT('0', 0 <= y ? 4 : 5, "ld", y);
@@ -241,7 +242,8 @@
 	    continue;
 
 	  case 'g':	/* year of ISO week without a century */
-	    v = NUM2INT(mod(tmx_cwyear, INT2FIX(100)));
+	  case 'y':	/* year without a century */
+	    v = NUM2INT(mod((*format == 'g') ? tmx_cwyear : tmx_year, INT2FIX(100)));
 	    FMT('0', 2, "d", v);
 	    continue;
 
@@ -402,24 +404,6 @@
 	    STRFTIME("%m/%d/%y");
 	    continue;
 
-	  case 'Y':	/* year with century */
-	    {
-		VALUE year = tmx_year;
-		if (FIXNUM_P(year)) {
-		    long y = FIX2LONG(year);
-		    FMT('0', 0 <= y ? 4 : 5, "ld", y);
-		}
-		else {
-		    FMTV('0', 4, "d", year);
-		}
-	    }
-	    continue;
-
-	  case 'y':	/* year without a century, 00 - 99 */
-	    v = NUM2INT(mod(tmx_year, INT2FIX(100)));
-	    FMT('0', 2, "d", v);
-	    continue;
-
 	  case 'Z':	/* time zone name or abbreviation */
 	    if (flags & BIT_OF(CHCASE)) {
 		flags &= ~(BIT_OF(UPPER) | BIT_OF(CHCASE));

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

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