Module: TimeUnits

Included in:
Integer
Defined in:
lib/units-time.rb

Constant Summary collapse

HOUR_IN_SECONDS =

60 minutes * 60 seconds

60 * 60
DAY_IN_SECONDS =

24 hours * 60 * 60

24 * HOUR_IN_SECONDS
WEEK_IN_SECONDS =

7 days * 24 * 60 * 60

7 * DAY_IN_SECONDS
FORTNIGHT_IN_SECONDS =

14 days * 24 * 60 * 60

14 * DAY_IN_SECONDS
YEAR_IN_SECONDS =

note: for year use 365 days for now and NOT 365.25 (1/4)

- why? why not? discuss
365 * DAY_IN_SECONDS

Instance Method Summary collapse

Instance Method Details

#dayObject Also known as: days



51
# File 'lib/units-time.rb', line 51

def day()       Timedelta.new( self * DAY_IN_SECONDS );  end

#fortnightObject Also known as: fortnights



53
# File 'lib/units-time.rb', line 53

def fortnight() Timedelta.new( self * FORTNIGHT_IN_SECONDS ); end

#hourObject Also known as: hours



50
# File 'lib/units-time.rb', line 50

def hour()      Timedelta.new( self * HOUR_IN_SECONDS ); end

#minuteObject Also known as: minutes, mins, min



49
# File 'lib/units-time.rb', line 49

def minute()    Timedelta.new( self * 60 ); end

#secondObject Also known as: seconds, secs, sec

365 days * 24 * 60 * 60



48
# File 'lib/units-time.rb', line 48

def second()    Timedelta.new( self ); end

#weekObject Also known as: weeks



52
# File 'lib/units-time.rb', line 52

def week()      Timedelta.new( self * WEEK_IN_SECONDS ); end

#yearObject Also known as: years



54
# File 'lib/units-time.rb', line 54

def year()      Timedelta.new( self * YEAR_IN_SECONDS ); end