Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Date#+

d + other → date

Returns a date object pointing other days after self. The other should be a numeric value. If the other is a fractional number, assumes its precision is at most nanosecond.

Example
Date.new(2001,2,3) + 1    #=> #<Date: 2001-02-04 ...>
DateTime.new(2001,2,3) + Rational(1,2)
                          #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
DateTime.new(2001,2,3) + Rational(-1,2)
                          #=> #<DateTime: 2001-02-02T12:00:00+00:00 ...>
DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd
                          #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
See also .xmlschema #- ._xmlschema #<< also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1