Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.

If you need precise date calculations that doesn’t just treat months as 30 days, then have a look at Time#advance.

Some of these methods are approximations, Ruby’s core Date and Time should be used for precision date and time arithmetic

Methods
A
D
F
H
M
S
U
W
Y
Instance Public methods
ago(time = ::Time.now)

Reads best without arguments: 10.minutes.ago

Also aliased as: until
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 55
def ago(time = ::Time.now)
  time - self
end
day()
days()
Also aliased as: day
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 29
def days
  self * 24.hours
end
fortnight()
fortnights()
Also aliased as: fortnight
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 39
def fortnights
  self * 2.weeks
end
from_now(time = ::Time.now)

Reads best without arguments: 10.minutes.from_now

hour()
hours()
Also aliased as: hour
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 24
def hours
  self * 60.minutes
end
minute()
minutes()
Also aliased as: minute
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 19
def minutes
  self * 60
end
month()
months()
Also aliased as: month
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 44
def months
  self * 30.days
end
second()
seconds()
Also aliased as: second
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 14
def seconds
  self
end
since(time = ::Time.now)

Reads best with argument: 10.minutes.since(time)

Also aliased as: from_now
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 63
def since(time = ::Time.now)
  time + self
end
until(time = ::Time.now)

Reads best with argument: 10.minutes.until(time)

week()
weeks()
Also aliased as: week
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 34
def weeks
  self * 7.days
end
year()
years()
Also aliased as: year
# File rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 49
def years
  (self * 365.25.days).to_i
end