instance method
advance
Ruby on Rails 6.0.6
Since v3.0.20Signature
advance(options)
Provides precise Date calculations for years, months, and days. The options parameter takes a hash with any of these keys: :years, :months, :weeks, :days.
Parameters
-
optionsreq
Source
# File activesupport/lib/active_support/core_ext/date/calculations.rb, line 112
def advance(options)
d = self
d = d >> options[:years] * 12 if options[:years]
d = d >> options[:months] if options[:months]
d = d + options[:weeks] * 7 if options[:weeks]
d = d + options[:days] if options[:days]
d
end
Defined in activesupport/lib/active_support/core_ext/date/calculations.rb line 112
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Date