Sha256: 68547645780f3752682dd28648e3c1edbc286d7b6de8fd2eccec7ee37b567b7a
Contents?: true
Size: 821 Bytes
Versions: 1
Compression:
Stored size: 821 Bytes
Contents
module Abaci require "active_support/core_ext/time" class DateRange attr_reader :start, :finish def initialize(start, finish) if start < finish @start = start @finish = finish else @start = finish @finish = start end end def days range.to_a end def keys days.map { |d| d.strftime("%Y:%-m:%-d") } end def range start..finish end def self.ago(days = 30) seconds = days.to_i * 86400 start = (now.to_date - Rational(seconds, 86400)).to_date new(start, now.to_date) end def self.between(start, finish) new(start, finish) end def self.now Time.now.in_time_zone(Abaci.time_zone) end def self.since(date) new(date, now.to_date) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
abaci-0.3.0 | lib/abaci/date_range.rb |