Sha256: a2c5a9f46b1ba1a33d2d5baab35218266c95a620be1e8daf5c7bdd80ff4343d8

Contents?: true

Size: 428 Bytes

Versions: 8

Compression:

Stored size: 428 Bytes

Contents

module Tabs
  module Resolutions
    module Month
      extend self

      PATTERN = "%Y-%m"

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

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

      def from_seconds(s)
        s / 1728000
      end

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

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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