method

months_since

Importance_0
v1.2.6 - Show latest stable - 0 notes - Class: ActiveSupport::CoreExtensions::Time::Calculations
months_since(months) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 77
        def months_since(months)
          year, month, mday = self.year, self.month, self.mday

          month += months

          # in case months is negative
          while month < 1
            month += 12
            year -= 1
          end

          # in case months is positive
          while month > 12
            month -= 12
            year += 1
          end

          max = ::Time.days_in_month(month, year)
          mday = max if mday > max

          change(:year => year, :month => month, :mday => mday)
        end
Register or log in to add new notes.