@@ -6311,10 +6311,15 @@ d_lite_prev_day(int argc, VALUE *argv, VALUE self)
63116311
63126312/*
63136313 * call-seq:
6314- * d.succ -> date
6315- * d.next -> date
6314+ * d.next -> new_date
63166315 *
6317- * Returns a date object denoting the following day.
6316+ * Returns a new \Date object representing the following day:
6317+ *
6318+ * d = Date.today
6319+ * d.to_s # => "2022-07-11"
6320+ * d.next.to_s # => "2022-07-12"
6321+ *
6322+ * Date#succ is an alias for Date#next.
63186323 */
63196324static VALUE
63206325d_lite_next (VALUE self )
@@ -6324,26 +6329,30 @@ d_lite_next(VALUE self)
63246329
63256330/*
63266331 * call-seq:
6327- * d >> n -> date
6332+ * d >> n -> new_date
63286333 *
6329- * Returns a date object pointing +n+ months after self.
6330- * The argument +n+ should be a numeric value.
6334+ * Returns a new \Date object representing the date
6335+ * +n+ months later; +n+ should be a numeric:
63316336 *
6332- * Date.new(2001,2, 3) >> 1 # => #<Date: 2001-03-03 ...>
6333- * Date.new(2001,2, 3) >> -2 # => #<Date: 2000-12-03 ...>
6337+ * ( Date.new(2001, 2, 3) >> 1).to_s # => " 2001-03-03"
6338+ * ( Date.new(2001, 2, 3) >> -2).to_s # => " 2000-12-03"
63346339 *
6335- * When the same day does not exist for the corresponding month,
6336- * the last day of the month is used instead:
6340+ * When the same day does not exist for the new month,
6341+ * the last day of that month is used instead:
63376342 *
6338- * Date.new(2001,1,28 ) >> 1 # => #<Date: 2001-02-28 ...>
6339- * Date.new(2001,1, 31) >> 1 # => #<Date: 2001-02-28 ...>
6343+ * ( Date.new(2001, 1, 31 ) >> 1).to_s # => " 2001-02-28"
6344+ * ( Date.new(2001, 1, 31) >> -4).to_s # => "2000-09-30"
63406345 *
6341- * This also results in the following, possibly unexpected, behavior :
6346+ * This results in the following, possibly unexpected, behaviors :
63426347 *
6343- * Date.new(2001,1,31) >> 2 #=> #<Date: 2001-03-31 ...>
6344- * Date.new(2001,1,31) >> 1 >> 1 #=> #<Date: 2001-03-28 ...>
6348+ * d0 = Date.new(2001, 1, 31)
6349+ * d1 = d0 >> 1 # => #<Date: 2001-02-28>
6350+ * d2 = d1 >> 1 # => #<Date: 2001-03-28>
6351+ *
6352+ * d0 = Date.new(2001, 1, 31)
6353+ * d1 = d0 >> 1 # => #<Date: 2001-02-28>
6354+ * d2 = d1 >> -1 # => #<Date: 2001-01-28>
63456355 *
6346- * Date.new(2001,1,31) >> 1 >> -1 #=> #<Date: 2001-01-28 ...>
63476356 */
63486357static VALUE
63496358d_lite_rshift (VALUE self , VALUE other )
@@ -6388,24 +6397,28 @@ d_lite_rshift(VALUE self, VALUE other)
63886397 * call-seq:
63896398 * d << n -> date
63906399 *
6391- * Returns a date object pointing +n+ months before self.
6392- * The argument +n+ should be a numeric value.
6400+ * Returns a new \Date object representing the date
6401+ * +n+ months earlier; +n+ should be a numeric:
6402+ *
6403+ * (Date.new(2001, 2, 3) << 1).to_s # => "2001-01-03"
6404+ * (Date.new(2001, 2, 3) << -2).to_s # => "2001-04-03"
63936405 *
6394- * Date.new(2001,2,3) << 1 #=> #<Date: 2001-01-03 ...>
6395- * Date.new(2001,2,3) << -2 #=> #<Date: 2001-04-03 ...>
6406+ * When the same day does not exist for the new month,
6407+ * the last day of that month is used instead:
63966408 *
6397- * When the same day does not exist for the corresponding month,
6398- * the last day of the month is used instead:
6409+ * (Date.new(2001, 3, 31) << 1).to_s # => "2001-02-28"
6410+ * (Date.new(2001, 3, 31) << -6).to_s # => "2001-09-30"
63996411 *
6400- * Date.new(2001,3,28) << 1 #=> #<Date: 2001-02-28 ...>
6401- * Date.new(2001,3,31) << 1 #=> #<Date: 2001-02-28 ...>
6412+ * This results in the following, possibly unexpected, behaviors:
64026413 *
6403- * This also results in the following, possibly unexpected, behavior:
6414+ * d0 = Date.new(2001, 3, 31)
6415+ * d0 << 2 # => #<Date: 2001-01-31>
6416+ * d0 << 1 << 1 # => #<Date: 2001-01-28>
64046417 *
6405- * Date.new(2001,3,31) << 2 #=> #<Date: 2001-01-31 ...>
6406- * Date.new(2001,3,31) << 1 << 1 #=> #<Date: 2001-01-28 ...>
6418+ * d0 = Date.new(2001, 3, 31)
6419+ * d1 = d0 << 1 # => #<Date: 2001-02-28>
6420+ * d2 = d1 << -1 # => #<Date: 2001-03-28>
64076421 *
6408- * Date.new(2001,3,31) << 1 << -1 #=> #<Date: 2001-03-28 ...>
64096422 */
64106423static VALUE
64116424d_lite_lshift (VALUE self , VALUE other )
@@ -6416,11 +6429,9 @@ d_lite_lshift(VALUE self, VALUE other)
64166429
64176430/*
64186431 * call-seq:
6419- * d. next_month([n=1]) -> date
6432+ * next_month(n = 1) -> new_date
64206433 *
6421- * This method is equivalent to d >> n.
6422- *
6423- * See Date#>> for examples.
6434+ * Equivalent to #>> with argument +n+.
64246435 */
64256436static VALUE
64266437d_lite_next_month (int argc , VALUE * argv , VALUE self )
@@ -6435,11 +6446,9 @@ d_lite_next_month(int argc, VALUE *argv, VALUE self)
64356446
64366447/*
64376448 * call-seq:
6438- * d.prev_month([n=1]) -> date
6439- *
6440- * This method is equivalent to d << n.
6449+ * prev_month(n = 1) -> new_date
64416450 *
6442- * See Date #<< for examples .
6451+ * Equivalent to #<< with argument +n+ .
64436452 */
64446453static VALUE
64456454d_lite_prev_month (int argc , VALUE * argv , VALUE self )
@@ -6454,15 +6463,9 @@ d_lite_prev_month(int argc, VALUE *argv, VALUE self)
64546463
64556464/*
64566465 * call-seq:
6457- * d.next_year([n=1]) -> date
6458- *
6459- * This method is equivalent to d >> (n * 12).
6460- *
6461- * Date.new(2001,2,3).next_year #=> #<Date: 2002-02-03 ...>
6462- * Date.new(2008,2,29).next_year #=> #<Date: 2009-02-28 ...>
6463- * Date.new(2008,2,29).next_year(4) #=> #<Date: 2012-02-29 ...>
6466+ * next_year(n = 1) -> new_date
64646467 *
6465- * See also Date#> >.
6468+ * Equivalent to #>> with argument <tt>n * 12</tt >.
64666469 */
64676470static VALUE
64686471d_lite_next_year (int argc , VALUE * argv , VALUE self )
@@ -6477,15 +6480,9 @@ d_lite_next_year(int argc, VALUE *argv, VALUE self)
64776480
64786481/*
64796482 * call-seq:
6480- * d. prev_year([n=1]) -> date
6483+ * prev_year(n = 1) -> new_date
64816484 *
6482- * This method is equivalent to d << (n * 12).
6483- *
6484- * Date.new(2001,2,3).prev_year #=> #<Date: 2000-02-03 ...>
6485- * Date.new(2008,2,29).prev_year #=> #<Date: 2007-02-28 ...>
6486- * Date.new(2008,2,29).prev_year(4) #=> #<Date: 2004-02-29 ...>
6487- *
6488- * See also Date#<<.
6485+ * Equivalent to #<< with argument <tt>n * 12</tt>.
64896486 */
64906487static VALUE
64916488d_lite_prev_year (int argc , VALUE * argv , VALUE self )
@@ -6502,14 +6499,33 @@ static VALUE d_lite_cmp(VALUE, VALUE);
65026499
65036500/*
65046501 * call-seq:
6505- * d.step(limit[, step=1]) -> enumerator
6506- * d.step(limit[, step=1]){|date| ...} -> self
6502+ * step(limit, step = 1){|date| ... } -> self
6503+ *
6504+ * Calls the block with specified dates;
6505+ * returns +self+.
6506+ *
6507+ * - The first +date+ is +self+.
6508+ * - Each successive +date+ is <tt>date + step</tt>,
6509+ * where +step+ is the numeric step size in days.
6510+ * - The last date is the last one that is before or equal to +limit+,
6511+ * which should be a \Date object.
6512+ *
6513+ * Example:
6514+ *
6515+ * limit = Date.new(2001, 12, 31)
6516+ * Date.new(2001).step(limit){|date| p date.to_s if date.mday == 31 }
6517+ *
6518+ * Output:
65076519 *
6508- * Iterates evaluation of the given block, which takes a date object.
6509- * The limit should be a date object.
6520+ * "2001-01-31"
6521+ * "2001-03-31"
6522+ * "2001-05-31"
6523+ * "2001-07-31"
6524+ * "2001-08-31"
6525+ * "2001-10-31"
6526+ * "2001-12-31"
65106527 *
6511- * Date.new(2001).step(Date.new(2001,-1,-1)).select{|d| d.sunday?}.size
6512- * #=> 52
6528+ * Returns an Enumerator if no block is given.
65136529 */
65146530static VALUE
65156531d_lite_step (int argc , VALUE * argv , VALUE self )
@@ -6552,10 +6568,9 @@ d_lite_step(int argc, VALUE *argv, VALUE self)
65526568
65536569/*
65546570 * call-seq:
6555- * d.upto(max) -> enumerator
6556- * d.upto(max){|date| ...} -> self
6571+ * upto(max){|date| ... } -> self
65576572 *
6558- * This method is equivalent to step( max, 1){|date| ...} .
6573+ * Equivalent to #step with arguments + max+ and +1+ .
65596574 */
65606575static VALUE
65616576d_lite_upto (VALUE self , VALUE max )
@@ -6574,10 +6589,9 @@ d_lite_upto(VALUE self, VALUE max)
65746589
65756590/*
65766591 * call-seq:
6577- * d.downto(min) -> enumerator
6578- * d.downto(min){|date| ...} -> self
6592+ * downto(min){|date| ... } -> self
65796593 *
6580- * This method is equivalent to step( min, -1){|date| ...} .
6594+ * Equivalent to #step with arguments + min+ and <tt>-1</tt> .
65816595 */
65826596static VALUE
65836597d_lite_downto (VALUE self , VALUE min )
0 commit comments