Sha256: beaddc3271dda3e17410c1463bfc278ae1f034a008543776857b536ac7e532f9
Contents?: true
Size: 702 Bytes
Versions: 1
Compression:
Stored size: 702 Bytes
Contents
module Abaci 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 = (Date.today - Rational(seconds, 86400)).to_date new(start, Date.today) end def self.between(start, finish) new(start, finish) end def self.since(date) new(date, Date.today) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
abaci-0.2.0 | lib/abaci/date_range.rb |