Sha256: 9e1df907a5713b38833c347aa06acf9b73f0b0ceb863e7a0c5b265437f593df5
Contents?: true
Size: 611 Bytes
Versions: 2
Compression:
Stored size: 611 Bytes
Contents
module Tabs module Resolutions module Day include Tabs::Resolutionable extend self PATTERN = "%Y-%m-%d" def name :day end def serialize(timestamp) timestamp.strftime(PATTERN) end def deserialize(str) dt = DateTime.strptime(str, PATTERN) self.normalize(dt) end def from_seconds(s) s / 1.day end def to_seconds 1.day end def add(ts, num) ts + num.days end def normalize(ts) Time.utc(ts.year, ts.month, ts.day) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tabs-1.0.1 | lib/tabs/resolutions/day.rb |
tabs-1.0.0 | lib/tabs/resolutions/day.rb |