Sha256: 2924bc2ff96316c101001736254003abe919632994bedc0a05b9f832a3128c58

Contents?: true

Size: 460 Bytes

Versions: 8

Compression:

Stored size: 460 Bytes

Contents

module Tabs
  module Resolutions
    module Minute
      extend self

      PATTERN = "%Y-%m-%d-%H-%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 / 60.0
      end

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

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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