instance method >>

Ruby on Rails 3.1.12

Since v3.0.20 Last seen in v3.2.22.5

Available in: v3.0.20 v3.1.12 v3.2.22.5

Signature

>>(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

n req
Source
# File activesupport/lib/active_support/core_ext/date/calculations.rb, line 16
    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 16 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Date

Type at least 2 characters to search.

↑↓ navigate · open · esc close