Module: Assistance::TimeCalculations
- Included in:
- Numeric
- Defined in:
- lib/assistance/time_calculations.rb
Constant Summary collapse
- MINUTE =
60
- HOUR =
3600
- DAY =
86400
- WEEK =
DAY * 7
Instance Method Summary collapse
-
#ago(t = Time.now) ⇒ Object
(also: #before)
Returns the time at now - self.
-
#days ⇒ Object
(also: #day)
Converts self from days to seconds.
-
#from_now(t = Time.now) ⇒ Object
(also: #since)
Returns the time at now + self.
-
#hours ⇒ Object
(also: #hour)
Converts self from hours to seconds.
-
#minutes ⇒ Object
(also: #minute)
Converts self from minutes to seconds.
-
#weeks ⇒ Object
(also: #week)
Converts self from weeks to seconds.
Instance Method Details
#ago(t = Time.now) ⇒ Object Also known as: before
Returns the time at now - self.
23 |
# File 'lib/assistance/time_calculations.rb', line 23 def ago(t = Time.now); t - self; end |
#days ⇒ Object Also known as: day
Converts self from days to seconds
18 |
# File 'lib/assistance/time_calculations.rb', line 18 def days; self * DAY; end |
#from_now(t = Time.now) ⇒ Object Also known as: since
Returns the time at now + self.
27 |
# File 'lib/assistance/time_calculations.rb', line 27 def from_now(t = Time.now); t + self; end |
#hours ⇒ Object Also known as: hour
Converts self from hours to seconds
16 |
# File 'lib/assistance/time_calculations.rb', line 16 def hours; self * HOUR; end |