Sha256: b9873a9093cc1382d0d11281434c7dfb3aff488bbed4e029c3637d60e3fc5bea

Contents?: true

Size: 449 Bytes

Versions: 1

Compression:

Stored size: 449 Bytes

Contents

module Tabs
  module Resolutions
    module Year
      extend Tabs::Resolutionable
      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

1 entries across 1 versions & 1 rubygems

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