Sha256: bb28846a1d4cca8b4be6bec5c1226d614cf8b8edc47c90ae63dd6c781e8055a8
Contents?: true
Size: 544 Bytes
Versions: 8
Compression:
Stored size: 544 Bytes
Contents
module Tabs module Resolutions module Week 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
8 entries across 8 versions & 1 rubygems