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

ruby-changes:46054

From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 03:36:34 +0900 (JST)
Subject: [ruby-changes:46054] usa:r58125 (ruby_2_2): merge revision(s) 57737: [Backport #13225]

usa	2017-03-26 03:36:29 +0900 (Sun, 26 Mar 2017)

  New Revision: 58125

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

  Log:
    merge revision(s) 57737: [Backport #13225]
    
    date_core.c: expand docs for Date shifting
    
    * ext/date/date_core.c: [DOC] expand docs for Date shifting
    
      * add examples for Date#>> and Date#<< that clarify some edge cases
      * add examples for Date#next_year and Date#prev_year
      * add cross references to Date#>> and Date#<<
    
      [ruby-core:79584] [Bug #13225]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ext/date/date_core.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 58124)
+++ ruby_2_2/version.h	(revision 58125)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 457
+#define RUBY_PATCHLEVEL 458
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2/ext/date/date_core.c
===================================================================
--- ruby_2_2/ext/date/date_core.c	(revision 58124)
+++ ruby_2_2/ext/date/date_core.c	(revision 58125)
@@ -5965,9 +5965,20 @@ d_lite_next(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/date/date_core.c#L5965
  * The argument +n+ should be a numeric value.
  *
  *    Date.new(2001,2,3)  >>  1   #=> #<Date: 2001-03-03 ...>
- *    Date.new(2001,1,30) >>  1   #=> #<Date: 2001-02-28 ...>
- *    Date.new(2001,1,31) >>  1   #=> #<Date: 2001-02-28 ...>
  *    Date.new(2001,2,3)  >> -2   #=> #<Date: 2000-12-03 ...>
+ *
+ * When the same day does not exist for the corresponding month,
+ * the last day of the month is used instead:
+ *
+ *    Date.new(2001,1,28) >> 1   #=> #<Date: 2001-02-28 ...>
+ *    Date.new(2001,1,31) >> 1   #=> #<Date: 2001-02-28 ...>
+ *
+ * This also results in the following, possibly unexpected, behavior:
+ *
+ *    Date.new(2001,1,31) >> 2         #=> #<Date: 2001-03-31 ...>
+ *    Date.new(2001,1,31) >> 1 >> 1    #=> #<Date: 2001-03-28 ...>
+ *
+ *    Date.new(2001,1,31) >> 1 >> -1   #=> #<Date: 2001-01-28 ...>
  */
 static VALUE
 d_lite_rshift(VALUE self, VALUE other)
@@ -6016,9 +6027,20 @@ d_lite_rshift(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/date/date_core.c#L6027
  * The argument +n+ should be a numeric value.
  *
  *    Date.new(2001,2,3)  <<  1   #=> #<Date: 2001-01-03 ...>
- *    Date.new(2001,1,30) << 11   #=> #<Date: 2000-02-29 ...>
- *    Date.new(2001,1,31) << 11   #=> #<Date: 2000-02-29 ...>
- *    Date.new(2001,2,3)  << -1   #=> #<Date: 2001-03-03 ...>
+ *    Date.new(2001,2,3)  << -2   #=> #<Date: 2001-04-03 ...>
+ *
+ * When the same day does not exist for the corresponding month,
+ * the last day of the month is used instead:
+ *
+ *    Date.new(2001,3,28) << 1   #=> #<Date: 2001-02-28 ...>
+ *    Date.new(2001,3,31) << 1   #=> #<Date: 2001-02-28 ...>
+ *
+ * This also results in the following, possibly unexpected, behavior:
+ *
+ *    Date.new(2001,3,31) << 2         #=> #<Date: 2001-01-31 ...>
+ *    Date.new(2001,3,31) << 1 << 1    #=> #<Date: 2001-01-28 ...>
+ *
+ *    Date.new(2001,3,31) << 1 << -1   #=> #<Date: 2001-03-28 ...>
  */
 static VALUE
 d_lite_lshift(VALUE self, VALUE other)
@@ -6031,6 +6053,8 @@ d_lite_lshift(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/date/date_core.c#L6053
  *    d.next_month([n=1])  ->  date
  *
  * This method is equivalent to d >> n.
+ *
+ * See Date#>> for examples.
  */
 static VALUE
 d_lite_next_month(int argc, VALUE *argv, VALUE self)
@@ -6048,6 +6072,8 @@ d_lite_next_month(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/date/date_core.c#L6072
  *    d.prev_month([n=1])  ->  date
  *
  * This method is equivalent to d << n.
+ *
+ * See Date#<< for examples.
  */
 static VALUE
 d_lite_prev_month(int argc, VALUE *argv, VALUE self)
@@ -6065,6 +6091,12 @@ d_lite_prev_month(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/date/date_core.c#L6091
  *    d.next_year([n=1])  ->  date
  *
  * This method is equivalent to d >> (n * 12).
+ *
+ *    Date.new(2001,2,3).next_year      #=> #<Date: 2002-02-03 ...>
+ *    Date.new(2008,2,29).next_year     #=> #<Date: 2009-02-28 ...>
+ *    Date.new(2008,2,29).next_year(4)  #=> #<Date: 2012-02-29 ...>
+ *
+ * See also Date#>>.
  */
 static VALUE
 d_lite_next_year(int argc, VALUE *argv, VALUE self)
@@ -6082,6 +6114,12 @@ d_lite_next_year(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/date/date_core.c#L6114
  *    d.prev_year([n=1])  ->  date
  *
  * This method is equivalent to d << (n * 12).
+ *
+ *    Date.new(2001,2,3).prev_year      #=> #<Date: 2000-02-03 ...>
+ *    Date.new(2008,2,29).prev_year     #=> #<Date: 2007-02-28 ...>
+ *    Date.new(2008,2,29).prev_year(4)  #=> #<Date: 2004-02-29 ...>
+ *
+ * See also Date#<<.
  */
 static VALUE
 d_lite_prev_year(int argc, VALUE *argv, VALUE self)

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57737


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

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