instance method
>>
Ruby on Rails 3.0.20
Since v3.0.20 Last seen in v3.2.22.5Signature
>>(n)
Backported from 1.9. The one in 1.8 leads to incorrect next_month and friends for dates where the calendar reform is involved. It additionally prevents an infinite loop fixed in r27013.
Parameters
-
nreq
Source
# File activesupport/lib/active_support/core_ext/date/calculations.rb, line 14
def >>(n)
y, m = (year * 12 + (mon - 1) + n).divmod(12)
m, = (m + 1) .divmod(1)
d = mday
until jd2 = self.class.valid_civil?(y, m, d, start)
d -= 1
raise ArgumentError, 'invalid date' unless d > 0
end
self + (jd2 - jd)
end
Defined in activesupport/lib/active_support/core_ext/date/calculations.rb line 14
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Date