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

ruby-changes:33647

From: tadf <ko1@a...>
Date: Sun, 27 Apr 2014 19:44:30 +0900 (JST)
Subject: [ruby-changes:33647] tadf:r45728 (trunk): * ext/date/date_strptime.c (date__strptime_internal): do not overwrite century.

tadf	2014-04-27 19:44:23 +0900 (Sun, 27 Apr 2014)

  New Revision: 45728

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

  Log:
    * ext/date/date_strptime.c (date__strptime_internal): do not overwrite century.

  Modified files:
    trunk/ChangeLog
    trunk/ext/date/date_strptime.c
    trunk/test/date/test_date_strptime.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45727)
+++ ChangeLog	(revision 45728)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Apr 27 19:39:42 2014  Tadayoshi Funaba  <tadf@d...>
+
+	* ext/date/date_strptime.c (date__strptime_internal): do not overwrite century.
+
 Sat Apr 26 11:50:08 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* test/ruby/test_enum.rb (test_flat_map): Added test for flat_map.
Index: ext/date/date_strptime.c
===================================================================
--- ext/date/date_strptime.c	(revision 45727)
+++ ext/date/date_strptime.c	(revision 45728)
@@ -291,8 +291,9 @@ date__strptime_internal(const char *str, https://github.com/ruby/ruby/blob/trunk/ext/date/date_strptime.c#L291
 		    if (!valid_range_p(n, 0, 99))
 			fail();
 		    set_hash("cwyear",n);
-		    set_hash("_cent",
-			     INT2FIX(f_ge_p(n, INT2FIX(69)) ? 19 : 20));
+		    if (NIL_P(ref_hash("_cent")))
+			set_hash("_cent",
+				 INT2FIX(f_ge_p(n, INT2FIX(69)) ? 19 : 20));
 		    goto matched;
 		}
 
@@ -556,8 +557,9 @@ date__strptime_internal(const char *str, https://github.com/ruby/ruby/blob/trunk/ext/date/date_strptime.c#L557
 		    if (sign == -1)
 			n = f_negate(n);
 		    set_hash("year", n);
-		    set_hash("_cent",
-			     INT2FIX(f_ge_p(n, INT2FIX(69)) ? 19 : 20));
+		    if (NIL_P(ref_hash("_cent")))
+			set_hash("_cent",
+				 INT2FIX(f_ge_p(n, INT2FIX(69)) ? 19 : 20));
 		    goto matched;
 		}
 
Index: test/date/test_date_strptime.rb
===================================================================
--- test/date/test_date_strptime.rb	(revision 45727)
+++ test/date/test_date_strptime.rb	(revision 45728)
@@ -195,8 +195,12 @@ class TestDateStrptime < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/date/test_date_strptime.rb#L195
      [['01', '%y'], [2001,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
      [['19 99', '%C %y'], [1999,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
      [['20 01', '%C %y'], [2001,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
+     [['30 99', '%C %y'], [3099,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
+     [['30 01', '%C %y'], [3001,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
      [['1999', '%C%y'], [1999,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
      [['2001', '%C%y'], [2001,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
+     [['3099', '%C%y'], [3099,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
+     [['3001', '%C%y'], [3001,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
 
      [['20060806', '%Y'], [20060806,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],
      [['20060806', "%Y\s"], [20060806,nil,nil,nil,nil,nil,nil,nil,nil], __LINE__],

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

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