@@ -6340,10 +6340,15 @@ d_lite_prev_day(int argc, VALUE *argv, VALUE self)
63406340
63416341/*
63426342 * call-seq:
6343- * d.succ -> date
6344- * d.next -> date
6343+ * d.next -> new_date
63456344 *
6346- * Returns a date object denoting the following day.
6345+ * Returns a new \Date object representing the following day:
6346+ *
6347+ * d = Date.today
6348+ * d.to_s # => "2022-07-11"
6349+ * d.next.to_s # => "2022-07-12"
6350+ *
6351+ * Date#succ is an alias for Date#next.
63476352 */
63486353static VALUE
63496354d_lite_next (VALUE self )
@@ -6353,26 +6358,30 @@ d_lite_next(VALUE self)
63536358
63546359/*
63556360 * call-seq:
6356- * d >> n -> date
6361+ * d >> n -> new_date
63576362 *
6358- * Returns a date object pointing +n+ months after self.
6359- * The argument +n+ should be a numeric value.
6363+ * Returns a new \Date object representing the date
6364+ * +n+ months later; +n+ should be a numeric:
63606365 *
6361- * Date.new(2001,2, 3) >> 1 # => #<Date: 2001-03-03 ...>
6362- * Date.new(2001,2, 3) >> -2 # => #<Date: 2000-12-03 ...>
6366+ * ( Date.new(2001, 2, 3) >> 1).to_s # => " 2001-03-03"
6367+ * ( Date.new(2001, 2, 3) >> -2).to_s # => " 2000-12-03"
63636368 *
6364- * When the same day does not exist for the corresponding month,
6365- * the last day of the month is used instead:
6369+ * When the same day does not exist for the new month,
6370+ * the last day of that month is used instead:
63666371 *
6367- * Date.new(2001,1,28 ) >> 1 # => #<Date: 2001-02-28 ...>
6368- * Date.new(2001,1, 31) >> 1 # => #<Date: 2001-02-28 ...>
6372+ * ( Date.new(2001, 1, 31 ) >> 1).to_s # => " 2001-02-28"
6373+ * ( Date.new(2001, 1, 31) >> -4).to_s # => "2000-09-30"
63696374 *
6370- * This also results in the following, possibly unexpected, behavior :
6375+ * This results in the following, possibly unexpected, behaviors :
63716376 *
6372- * Date.new(2001,1,31) >> 2 #=> #<Date: 2001-03-31 ...>
6373- * Date.new(2001,1,31) >> 1 >> 1 #=> #<Date: 2001-03-28 ...>
6377+ * d0 = Date.new(2001, 1, 31)
6378+ * d1 = d0 >> 1 # => #<Date: 2001-02-28>
6379+ * d2 = d1 >> 1 # => #<Date: 2001-03-28>
6380+ *
6381+ * d0 = Date.new(2001, 1, 31)
6382+ * d1 = d0 >> 1 # => #<Date: 2001-02-28>
6383+ * d2 = d1 >> -1 # => #<Date: 2001-01-28>
63746384 *
6375- * Date.new(2001,1,31) >> 1 >> -1 #=> #<Date: 2001-01-28 ...>
63766385 */
63776386static VALUE
63786387d_lite_rshift (VALUE self , VALUE other )
@@ -6417,24 +6426,28 @@ d_lite_rshift(VALUE self, VALUE other)
64176426 * call-seq:
64186427 * d << n -> date
64196428 *
6420- * Returns a date object pointing +n+ months before self.
6421- * The argument +n+ should be a numeric value.
6429+ * Returns a new \Date object representing the date
6430+ * +n+ months earlier; +n+ should be a numeric:
6431+ *
6432+ * (Date.new(2001, 2, 3) << 1).to_s # => "2001-01-03"
6433+ * (Date.new(2001, 2, 3) << -2).to_s # => "2001-04-03"
64226434 *
6423- * Date.new(2001,2,3) << 1 #=> #<Date: 2001-01-03 ...>
6424- * Date.new(2001,2,3) << -2 #=> #<Date: 2001-04-03 ...>
6435+ * When the same day does not exist for the new month,
6436+ * the last day of that month is used instead:
64256437 *
6426- * When the same day does not exist for the corresponding month,
6427- * the last day of the month is used instead:
6438+ * (Date.new(2001, 3, 31) << 1).to_s # => "2001-02-28"
6439+ * (Date.new(2001, 3, 31) << -6).to_s # => "2001-09-30"
64286440 *
6429- * Date.new(2001,3,28) << 1 #=> #<Date: 2001-02-28 ...>
6430- * Date.new(2001,3,31) << 1 #=> #<Date: 2001-02-28 ...>
6441+ * This results in the following, possibly unexpected, behaviors:
64316442 *
6432- * This also results in the following, possibly unexpected, behavior:
6443+ * d0 = Date.new(2001, 3, 31)
6444+ * d0 << 2 # => #<Date: 2001-01-31>
6445+ * d0 << 1 << 1 # => #<Date: 2001-01-28>
64336446 *
6434- * Date.new(2001,3,31) << 2 #=> #<Date: 2001-01-31 ...>
6435- * Date.new(2001,3,31) << 1 << 1 #=> #<Date: 2001-01-28 ...>
6447+ * d0 = Date.new(2001, 3, 31)
6448+ * d1 = d0 << 1 # => #<Date: 2001-02-28>
6449+ * d2 = d1 << -1 # => #<Date: 2001-03-28>
64366450 *
6437- * Date.new(2001,3,31) << 1 << -1 #=> #<Date: 2001-03-28 ...>
64386451 */
64396452static VALUE
64406453d_lite_lshift (VALUE self , VALUE other )
@@ -6445,11 +6458,9 @@ d_lite_lshift(VALUE self, VALUE other)
64456458
64466459/*
64476460 * call-seq:
6448- * d. next_month([n=1]) -> date
6461+ * next_month(n = 1) -> new_date
64496462 *
6450- * This method is equivalent to d >> n.
6451- *
6452- * See Date#>> for examples.
6463+ * Equivalent to #>> with argument +n+.
64536464 */
64546465static VALUE
64556466d_lite_next_month (int argc , VALUE * argv , VALUE self )
@@ -6464,11 +6475,9 @@ d_lite_next_month(int argc, VALUE *argv, VALUE self)
64646475
64656476/*
64666477 * call-seq:
6467- * d.prev_month([n=1]) -> date
6468- *
6469- * This method is equivalent to d << n.
6478+ * prev_month(n = 1) -> new_date
64706479 *
6471- * See Date #<< for examples .
6480+ * Equivalent to #<< with argument +n+ .
64726481 */
64736482static VALUE
64746483d_lite_prev_month (int argc , VALUE * argv , VALUE self )
@@ -6483,15 +6492,9 @@ d_lite_prev_month(int argc, VALUE *argv, VALUE self)
64836492
64846493/*
64856494 * call-seq:
6486- * d.next_year([n=1]) -> date
6487- *
6488- * This method is equivalent to d >> (n * 12).
6489- *
6490- * Date.new(2001,2,3).next_year #=> #<Date: 2002-02-03 ...>
6491- * Date.new(2008,2,29).next_year #=> #<Date: 2009-02-28 ...>
6492- * Date.new(2008,2,29).next_year(4) #=> #<Date: 2012-02-29 ...>
6495+ * next_year(n = 1) -> new_date
64936496 *
6494- * See also Date#> >.
6497+ * Equivalent to #>> with argument <tt>n * 12</tt >.
64956498 */
64966499static VALUE
64976500d_lite_next_year (int argc , VALUE * argv , VALUE self )
@@ -6506,15 +6509,9 @@ d_lite_next_year(int argc, VALUE *argv, VALUE self)
65066509
65076510/*
65086511 * call-seq:
6509- * d. prev_year([n=1]) -> date
6512+ * prev_year(n = 1) -> new_date
65106513 *
6511- * This method is equivalent to d << (n * 12).
6512- *
6513- * Date.new(2001,2,3).prev_year #=> #<Date: 2000-02-03 ...>
6514- * Date.new(2008,2,29).prev_year #=> #<Date: 2007-02-28 ...>
6515- * Date.new(2008,2,29).prev_year(4) #=> #<Date: 2004-02-29 ...>
6516- *
6517- * See also Date#<<.
6514+ * Equivalent to #<< with argument <tt>n * 12</tt>.
65186515 */
65196516static VALUE
65206517d_lite_prev_year (int argc , VALUE * argv , VALUE self )
@@ -6531,14 +6528,33 @@ static VALUE d_lite_cmp(VALUE, VALUE);
65316528
65326529/*
65336530 * call-seq:
6534- * d.step(limit[, step=1]) -> enumerator
6535- * d.step(limit[, step=1]){|date| ...} -> self
6531+ * step(limit, step = 1){|date| ... } -> self
6532+ *
6533+ * Calls the block with specified dates;
6534+ * returns +self+.
6535+ *
6536+ * - The first +date+ is +self+.
6537+ * - Each successive +date+ is <tt>date + step</tt>,
6538+ * where +step+ is the numeric step size in days.
6539+ * - The last date is the last one that is before or equal to +limit+,
6540+ * which should be a \Date object.
6541+ *
6542+ * Example:
6543+ *
6544+ * limit = Date.new(2001, 12, 31)
6545+ * Date.new(2001).step(limit){|date| p date.to_s if date.mday == 31 }
6546+ *
6547+ * Output:
65366548 *
6537- * Iterates evaluation of the given block, which takes a date object.
6538- * The limit should be a date object.
6549+ * "2001-01-31"
6550+ * "2001-03-31"
6551+ * "2001-05-31"
6552+ * "2001-07-31"
6553+ * "2001-08-31"
6554+ * "2001-10-31"
6555+ * "2001-12-31"
65396556 *
6540- * Date.new(2001).step(Date.new(2001,-1,-1)).select{|d| d.sunday?}.size
6541- * #=> 52
6557+ * Returns an Enumerator if no block is given.
65426558 */
65436559static VALUE
65446560d_lite_step (int argc , VALUE * argv , VALUE self )
@@ -6581,10 +6597,9 @@ d_lite_step(int argc, VALUE *argv, VALUE self)
65816597
65826598/*
65836599 * call-seq:
6584- * d.upto(max) -> enumerator
6585- * d.upto(max){|date| ...} -> self
6600+ * upto(max){|date| ... } -> self
65866601 *
6587- * This method is equivalent to step( max, 1){|date| ...} .
6602+ * Equivalent to #step with arguments + max+ and +1+ .
65886603 */
65896604static VALUE
65906605d_lite_upto (VALUE self , VALUE max )
@@ -6603,10 +6618,9 @@ d_lite_upto(VALUE self, VALUE max)
66036618
66046619/*
66056620 * call-seq:
6606- * d.downto(min) -> enumerator
6607- * d.downto(min){|date| ...} -> self
6621+ * downto(min){|date| ... } -> self
66086622 *
6609- * This method is equivalent to step( min, -1){|date| ...} .
6623+ * Equivalent to #step with arguments + min+ and <tt>-1</tt> .
66106624 */
66116625static VALUE
66126626d_lite_downto (VALUE self , VALUE min )
0 commit comments