module AggtiveRecord::Time
Constants
- NON_UNIFORM_PERIODS
e.g. A year may have 365 days or 366
- OTHER_PERIODS
- PERIODS
- SECONDS_PER_DAY
- UNIFORM_PERIODS
A week is always 7 * 24 * 60 * 60, for instance
Public Class Methods
periods()
click to toggle source
todo: better naming convention
# File lib/aggtive_record/time.rb, line 17 def self.periods PERIODS + OTHER_PERIODS end
to_seconds(str)
click to toggle source
probably reinventing the wheel hereā¦
# File lib/aggtive_record/time.rb, line 24 def self.to_seconds(str) num, period = str.to_s.match(/^(\d*)_?(\w+?)s?$/)[1..2] num = num.to_i > 0 ? num.to_i : 1 # ugh secs = case period.to_sym when :year SECONDS_PER_DAY * 365 when :month SECONDS_PER_DAY * 30 when :week SECONDS_PER_DAY * 7 when :day SECONDS_PER_DAY when :hour 60 * 60 when :minute 60 when :second 1 end num * secs end