Sha256: 1091ec58aaa449d1bfe5e7dfb1de60fb0b57c81f305997ac64cd828a72873487

Contents?: true

Size: 415 Bytes

Versions: 8

Compression:

Stored size: 415 Bytes

Contents

module Tabs
  module Resolutions
    module Year
      extend self

      PATTERN = "%Y"

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

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

      def from_seconds(s)
        s / 31536000
      end

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

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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