Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years
Methods
- ago
- day
- days
- fortnight
- fortnights
- from_now
- hour
- hours
- minute
- minutes
- month
- months
- since
- until
- week
- weeks
- year
- years
Public Instance methods
Reads best without arguments: 10.minutes.ago
This method is also aliased as
until
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 42
42: def ago(time = ::Time.now)
43: time - self
44: end
Alias for days
This method is also aliased as
day
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 16
16: def days
17: self * 24.hours
18: end
Alias for fortnights
This method is also aliased as
fortnight
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 26
26: def fortnights
27: self * 2.weeks
28: end
Alias for since
Alias for hours
This method is also aliased as
hour
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 11
11: def hours
12: self * 60.minutes
13: end
Alias for minutes
This method is also aliased as
minute
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 6 6: def minutes 7: self * 60 8: end
Alias for months
This method is also aliased as
month
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 31
31: def months
32: self * 30.days
33: end
Reads best with argument: 10.minutes.since(time)
This method is also aliased as
from_now
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 50
50: def since(time = ::Time.now)
51: time + self
52: end
Alias for ago
Alias for weeks
This method is also aliased as
week
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 21
21: def weeks
22: self * 7.days
23: end
Alias for years
This method is also aliased as
year
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb, line 36
36: def years
37: self * 365.days
38: end