Sha256: 9a81369cf6078c402d22a858a3b90da1087d9878ca0d05a1add7708d6ce9d439
Contents?: true
Size: 578 Bytes
Versions: 1
Compression:
Stored size: 578 Bytes
Contents
module Tabs module Resolutions module Week extend Tabs::Resolutionable extend self PATTERN = "%Y-%W" def serialize(timestamp) timestamp.strftime(PATTERN) end def deserialize(str) year, week = str.split("-").map(&:to_i) week = 1 if week == 0 dt = DateTime.strptime("#{year}-#{week}", PATTERN) self.normalize(dt) end def from_seconds(s) s / 432000 end def normalize(ts) Time.utc(ts.year, ts.month, ts.day).beginning_of_week end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tabs-0.9.0 | lib/tabs/resolutions/week.rb |