Uses Date to provide precise Time calculations for years, months, and days. The
options parameter takes a hash with any of these keys:
:years,:months,:weeks,:days,:hours,:minutes,:seconds.
# File activesupport/lib/active_support/core_ext/date_time/calculations.rb, line 72
def advance(options)
d = to_date.advance(options)
datetime_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day)
seconds_to_advance = options.fetch(:seconds, 0) +
options.fetch(:minutes, 0) * 60 +
options.fetch(:hours, 0) * 3600
if seconds_to_advance.zero?
datetime_advanced_by_date
else
datetime_advanced_by_date.since seconds_to_advance
end
end