tags:

views:

71

answers:

2

In C#, There is a method AddDays([number of days]) in DateTime class.

Is there any kind of method like this in ruby?

+2  A: 

From the Date class:

+(n)

Return a new Date object that is n days later than the current one.

n may be a negative value, in which case the new Date is earlier than the current one; however, #-() might be more intuitive.

If n is not a Numeric, a TypeError will be thrown. In particular, two Dates cannot be added to each other.

ire_and_curses
+3  A: 

The Date class provides a + operator that does just that.

>> d=Date.today
=> #<Date: 4910149/2,0,2299161>
>> d.to_s
=> "2009-08-31"
>> (d+3).to_s
=> "2009-09-03"
>>
Steve Weet