Feb
13
Date manipulation
You can add or subtract days or month from a
Dateobject:
+(n): add n number of days-(n): subtract n number of days>>(n): add n number of months<<(n): subtract n number of monthsHere are some examples:
$ irb >> date = Date.today # => #<Date: ...> >> date.to_s => "2010-01-26" >> tomorrow = date + 1 # => #<Date: ...> >> tomorrow.to_s => "2010-01-27" >> nextmonth = date >> 1 # => #<Date: ...> >> nextmonth.to_s => "2010-02-26"Read the documentation for a more precise description.