Sha256: c9d09bb7073d5ba30086879491509e280e4ac193bed4ff36d75151321e776ca7

Contents?: true

Size: 435 Bytes

Versions: 8

Compression:

Stored size: 435 Bytes

Contents

module Tabs
  module Resolutions
    module Day
      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

8 entries across 8 versions & 1 rubygems

Version Path
tabs-0.8.2 lib/tabs/resolutions/day.rb
tabs-0.8.1 lib/tabs/resolutions/day.rb
tabs-0.8.0 lib/tabs/resolutions/day.rb
tabs-0.7.1 lib/tabs/resolutions/day.rb
tabs-0.7.0 lib/tabs/resolutions/day.rb
tabs-0.6.3 lib/tabs/resolutions/day.rb
tabs-0.6.2 lib/tabs/resolutions/day.rb
tabs-0.6.1 lib/tabs/resolutions/day.rb