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

ruby-changes:54610

From: naruse <ko1@a...>
Date: Tue, 15 Jan 2019 17:53:46 +0900 (JST)
Subject: [ruby-changes:54610] naruse:r66825 (ruby_2_6): merge revision(s) 66735: [Backport #15506]

naruse	2019-01-15 17:53:40 +0900 (Tue, 15 Jan 2019)

  New Revision: 66825

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66825

  Log:
    merge revision(s) 66735: [Backport #15506]
    
    Fix mday overflow
    
    [ruby-core:90897] [Bug #15506]

  Modified directories:
    branches/ruby_2_6/
  Modified files:
    branches/ruby_2_6/lib/time.rb
    branches/ruby_2_6/test/test_time.rb
    branches/ruby_2_6/version.h
Index: ruby_2_6/lib/time.rb
===================================================================
--- ruby_2_6/lib/time.rb	(revision 66824)
+++ ruby_2_6/lib/time.rb	(revision 66825)
@@ -201,6 +201,9 @@ class Time https://github.com/ruby/ruby/blob/trunk/ruby_2_6/lib/time.rb#L201
       end
 
       if yday
+        unless (1..366) === yday
+          raise ArgumentError, "yday #{yday} out of range"
+        end
         mon, day = (yday-1).divmod(31)
         mon += 1
         day += 1
@@ -208,6 +211,12 @@ class Time https://github.com/ruby/ruby/blob/trunk/ruby_2_6/lib/time.rb#L211
         diff = yday - t.yday
         return t if diff.zero?
         day += diff
+        if day > 28 and day > (mday = month_days(off_year, mon))
+          if (mon += 1) > 12
+            raise ArgumentError, "yday #{yday} out of range"
+          end
+          day -= mday
+        end
         return make_time(date, year, nil, mon, day, hour, min, sec, sec_fraction, zone, now)
       end
 
@@ -433,7 +442,7 @@ class Time https://github.com/ruby/ruby/blob/trunk/ruby_2_6/lib/time.rb#L442
     #
     def strptime(date, format, now=self.now)
       d = Date._strptime(date, format)
-      raise ArgumentError, "invalid strptime format - `#{format}'" unless d
+      raise ArgumentError, "invalid date or strptime format - `#{date}' `#{format}'" unless d
       if seconds = d[:seconds]
         if sec_fraction = d[:sec_fraction]
           usec = sec_fraction * 1000000
Index: ruby_2_6/test/test_time.rb
===================================================================
--- ruby_2_6/test/test_time.rb	(revision 66824)
+++ ruby_2_6/test/test_time.rb	(revision 66825)
@@ -503,6 +503,10 @@ class TestTimeExtension < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/ruby_2_6/test/test_time.rb#L503
     assert_equal(0, t.hour)
     assert_equal(0, t.min)
     assert_equal(0, t.sec)
+    t = Time.strptime("2018-091", "%Y-%j")
+    assert_equal(2018, t.year)
+    assert_equal(4, t.mon)
+    assert_equal(1, t.day)
   end
 
   def test_nsec
Index: ruby_2_6/version.h
===================================================================
--- ruby_2_6/version.h	(revision 66824)
+++ ruby_2_6/version.h	(revision 66825)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_6/version.h#L1
 #define RUBY_VERSION "2.6.0"
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 9
+#define RUBY_PATCHLEVEL 10
 
 #define RUBY_RELEASE_YEAR 2019
 #define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 14
+#define RUBY_RELEASE_DAY 15
 
 #include "ruby/version.h"
 
Index: ruby_2_6
===================================================================
--- ruby_2_6	(revision 66824)
+++ ruby_2_6	(revision 66825)

Property changes on: ruby_2_6
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r66735

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

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