Sha256: 51c93441ed5fc4c583f950a3aad74230ad7f11acb1804fe75f5ebef57513ca97

Contents?: true

Size: 393 Bytes

Versions: 6

Compression:

Stored size: 393 Bytes

Contents

module Tabs
  module Resolutions
    module Hour
      extend self

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

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

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

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

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tabs-0.5.6 lib/tabs/resolutions/hour.rb
tabs-0.5.5 lib/tabs/resolutions/hour.rb
tabs-0.5.4 lib/tabs/resolutions/hour.rb
tabs-0.5.3 lib/tabs/resolutions/hour.rb
tabs-0.5.2 lib/tabs/resolutions/hour.rb
tabs-0.5.0 lib/tabs/resolutions/hour.rb