Sha256: fb94d9db5a650c58e0142c0888a5fd2797f63bfd0feb491fe005dc6b6aab2adc

Contents?: true

Size: 525 Bytes

Versions: 1

Compression:

Stored size: 525 Bytes

Contents

module BadlyFormedResolution
  extend Tabs::Resolutionable
  extend self
end

module WellFormedResolution
  extend Tabs::Resolutionable
  extend self

  PATTERN = "%Y-%m-%d-%H-%M-%S"

  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
  end

  def add(ts, num)
    ts + num.seconds
  end

  def normalize(ts)
    Time.utc(ts.year, ts.month, ts.day, ts.hour, ts.min, ts.sec)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tabs-0.9.1 spec/support/custom_resolutions.rb