Project

General

Profile

Bug #13225 ยป doc_date_shift.patch

stomar (Marcus Stollsteimer), 02/18/2017 08:50 AM

View differences:

ext/date/date_core.c
5969 5969
 * The argument +n+ should be a numeric value.
5970 5970
 *
5971 5971
 *    Date.new(2001,2,3)  >>  1   #=> #<Date: 2001-03-03 ...>
5972
 *    Date.new(2001,1,30) >>  1   #=> #<Date: 2001-02-28 ...>
5973
 *    Date.new(2001,1,31) >>  1   #=> #<Date: 2001-02-28 ...>
5974 5972
 *    Date.new(2001,2,3)  >> -2   #=> #<Date: 2000-12-03 ...>
5973
 *
5974
 * When the same day does not exist for the corresponding month,
5975
 * the last day of the month is used instead:
5976
 *
5977
 *    Date.new(2001,1,28) >> 1         #=> #<Date: 2001-02-28 ...>
5978
 *    Date.new(2001,1,31) >> 1         #=> #<Date: 2001-02-28 ...>
5979
 *
5980
 * This also results in the following, possibly unexpected, behavior:
5981
 *
5982
 *    Date.new(2001,1,31) >> 2         #=> #<Date: 2001-03-31 ...>
5983
 *    Date.new(2001,1,31) >> 1 >> 1    #=> #<Date: 2001-03-28 ...>
5984
 *
5985
 *    Date.new(2001,1,31) >> 1 >> -1   #=> #<Date: 2001-01-28 ...>
5975 5986
 */
5976 5987
static VALUE
5977 5988
d_lite_rshift(VALUE self, VALUE other)
......
6020 6031
 * The argument +n+ should be a numeric value.
6021 6032
 *
6022 6033
 *    Date.new(2001,2,3)  <<  1   #=> #<Date: 2001-01-03 ...>
6023
 *    Date.new(2001,1,30) << 11   #=> #<Date: 2000-02-29 ...>
6024
 *    Date.new(2001,1,31) << 11   #=> #<Date: 2000-02-29 ...>
6025
 *    Date.new(2001,2,3)  << -1   #=> #<Date: 2001-03-03 ...>
6034
 *    Date.new(2001,2,3)  << -2   #=> #<Date: 2001-04-03 ...>
6035
 *
6036
 * When the same day does not exist for the corresponding month,
6037
 * the last day of the month is used instead:
6038
 *
6039
 *    Date.new(2001,3,28) << 1         #=> #<Date: 2001-02-28 ...>
6040
 *    Date.new(2001,3,31) << 1         #=> #<Date: 2001-02-28 ...>
6041
 *
6042
 * This also results in the following, possibly unexpected, behavior:
6043
 *
6044
 *    Date.new(2001,3,31) << 2         #=> #<Date: 2001-01-31 ...>
6045
 *    Date.new(2001,3,31) << 1 << 1    #=> #<Date: 2001-01-28 ...>
6046
 *
6047
 *    Date.new(2001,3,31) << 1 << -1   #=> #<Date: 2001-03-28 ...>
6026 6048
 */
6027 6049
static VALUE
6028 6050
d_lite_lshift(VALUE self, VALUE other)
......
6036 6058
 *    d.next_month([n=1])  ->  date
6037 6059
 *
6038 6060
 * This method is equivalent to d >> n.
6061
 *
6062
 * See Date#>> for examples.
6039 6063
 */
6040 6064
static VALUE
6041 6065
d_lite_next_month(int argc, VALUE *argv, VALUE self)
......
6053 6077
 *    d.prev_month([n=1])  ->  date
6054 6078
 *
6055 6079
 * This method is equivalent to d << n.
6080
 *
6081
 * See Date#<< for examples.
6056 6082
 */
6057 6083
static VALUE
6058 6084
d_lite_prev_month(int argc, VALUE *argv, VALUE self)
......
6070 6096
 *    d.next_year([n=1])  ->  date
6071 6097
 *
6072 6098
 * This method is equivalent to d >> (n * 12).
6099
 *
6100
 *    Date.new(2001,2,3).next_year      #=> #<Date: 2002-02-03 ...>
6101
 *    Date.new(2008,2,29).next_year     #=> #<Date: 2009-02-28 ...>
6102
 *    Date.new(2008,2,29).next_year(4)  #=> #<Date: 2012-02-29 ...>
6103
 *
6104
 * See also Date#>>.
6073 6105
 */
6074 6106
static VALUE
6075 6107
d_lite_next_year(int argc, VALUE *argv, VALUE self)
......
6087 6119
 *    d.prev_year([n=1])  ->  date
6088 6120
 *
6089 6121
 * This method is equivalent to d << (n * 12).
6122
 *
6123
 *    Date.new(2001,2,3).prev_year      #=> #<Date: 2000-02-03 ...>
6124
 *    Date.new(2008,2,29).prev_year     #=> #<Date: 2007-02-28 ...>
6125
 *    Date.new(2008,2,29).prev_year(4)  #=> #<Date: 2004-02-29 ...>
6126
 *
6127
 * See also Date#<<.
6090 6128
 */
6091 6129
static VALUE
6092 6130
d_lite_prev_year(int argc, VALUE *argv, VALUE self)