Sha256: 22ef68d23dc2cd79aa79545ba15b7618bb50441f434ef6c8f311ca27c2a49368
Contents?: true
Size: 628 Bytes
Versions: 2
Compression:
Stored size: 628 Bytes
Contents
module Tabs module Resolutions module Hour include Tabs::Resolutionable extend self PATTERN = "%Y-%m-%d-%H" def name :hour 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.hour end def to_seconds 1.hour end def add(ts, num) ts + num.hours end def normalize(ts) Time.utc(ts.year, ts.month, ts.day, ts.hour) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tabs-1.0.1 | lib/tabs/resolutions/hour.rb |
tabs-1.0.0 | lib/tabs/resolutions/hour.rb |