Flowdock
>>(p1) public

Returns a date object pointing n months after self. The argument n should be a numeric value.

Date.new(2001,2,3)  >>  1   #=> #<Date: 2001-03-03 ...>
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 ...>
Show source
Register or log in to add new notes.