Sha256: 05f288111da1c551a8a79eccbca139363e240b2146f018716f09865deba5e7dc

Contents?: true

Size: 463 Bytes

Versions: 1

Compression:

Stored size: 463 Bytes

Contents

module Tabs
  module Resolutions
    module Day
      extend Resolutionable
      extend self

      PATTERN = "%Y-%m-%d"

      def serialize(timestamp)
        timestamp.strftime(PATTERN)
      end

      def deserialize(str)
        dt = DateTime.strptime(str, PATTERN)
        self.normalize(dt)
      end

      def from_seconds(s)
        s / 86400
      end

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tabs-0.9.0 lib/tabs/resolutions/day.rb