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

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

#daysObject 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

#hoursObject Also known as: hour

Converts self from hours to seconds



16
# File 'lib/assistance/time_calculations.rb', line 16

def hours;    self * HOUR;    end

#minutesObject Also known as: minute

Converts self from minutes to seconds



14
# File 'lib/assistance/time_calculations.rb', line 14

def minutes;  self * MINUTE;  end

#weeksObject Also known as: week

Converts self from weeks to seconds



20
# File 'lib/assistance/time_calculations.rb', line 20

def weeks;    self * WEEK;    end