module ActiveObject::Time

Public Instance Methods

count_centuries_since(time) click to toggle source
# File lib/active_object/time.rb, line 166
def count_centuries_since(time)
  count_seconds_since(time) / CENTURY
end
Also aliased as: count_centuries_until
count_centuries_until(time)
count_days_since(time) click to toggle source
# File lib/active_object/time.rb, line 172
def count_days_since(time)
  count_seconds_since(time) / DAY
end
Also aliased as: count_days_until
count_days_until(time)
Alias for: count_days_since
count_decades_since(time) click to toggle source
# File lib/active_object/time.rb, line 178
def count_decades_since(time)
  count_seconds_since(time) / DECADE
end
Also aliased as: count_decades_until
count_decades_until(time)
Alias for: count_decades_since
count_hours_since(time) click to toggle source
# File lib/active_object/time.rb, line 184
def count_hours_since(time)
  count_seconds_since(time) / HOUR
end
Also aliased as: count_hours_until
count_hours_until(time)
Alias for: count_hours_since
count_milleniums_since(time) click to toggle source
# File lib/active_object/time.rb, line 190
def count_milleniums_since(time)
  count_seconds_since(time) / MILLENNIUM
end
Also aliased as: count_milleniums_until
count_milleniums_until(time)
count_minutes_since(time) click to toggle source
# File lib/active_object/time.rb, line 196
def count_minutes_since(time)
  count_seconds_since(time) / MINUTE
end
Also aliased as: count_minutes_until
count_minutes_until(time)
Alias for: count_minutes_since
count_seconds_since(time) click to toggle source
# File lib/active_object/time.rb, line 202
def count_seconds_since(time)
  time = time.to_time if time.respond_to?(:to_time)

  (to_f - time.to_f).abs
end
Also aliased as: count_seconds_until
count_seconds_until(time)
Alias for: count_seconds_since
count_weeks_since(time) click to toggle source
# File lib/active_object/time.rb, line 210
def count_weeks_since(time)
  count_seconds_since(time) / WEEK
end
Also aliased as: count_weeks_until
count_weeks_until(time)
Alias for: count_weeks_since
count_years_since(time) click to toggle source
# File lib/active_object/time.rb, line 216
def count_years_since(time)
  count_seconds_since(time) / YEAR
end
Also aliased as: count_years_until
count_years_until(time)
Alias for: count_years_since
format(string) click to toggle source
# File lib/active_object/time.rb, line 222
def format(string)
  delimiters = string.scan(/\W+/)
  formatters = string.scan(/[a-z0-9_]+/i)
  string = formatters.map { |unit| "%#{STRING_UNITS.fetch(unit.to_sym)}#{delimiters.shift}" }

  strftime(string.join)
end
stamp(key = :datetime_iso)
Alias for: to_format
to_format(key = :datetime_iso) click to toggle source
# File lib/active_object/time.rb, line 230
def to_format(key = :datetime_iso)
  strftime(KEY_UNITS.fetch(key.to_sym))
end
Also aliased as: stamp