Is there an add_days in ruby datetime?

后端 未结 6 1284
生来不讨喜
生来不讨喜 2020-12-25 10:59

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

Is there any kind of method like this in ruby?

6条回答
  •  长发绾君心
    2020-12-25 11:36

    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.

提交回复
热议问题