Sha256: 386085ca959f1fca707326ed4b3606941ffe950ed27140c378ae4c996743029f

Contents?: true

Size: 476 Bytes

Versions: 3

Compression:

Stored size: 476 Bytes

Contents

require 'time'
require 'stamped/version'

# Useful extensions for converting time to and from iso8601 in UTC
module Stamped
  def self.included(base)
    base.extend(ClassMethods)
  end

  def stamp
    utc.iso8601
  end

  # Class methods for time
  module ClassMethods
    def from_stamp(timestamp)
      Time.iso8601(timestamp)
    end

    def stamp(time = now)
      time.stamp
    end

    def stamp_time
      from_stamp(stamp)
    end
  end
end

Time.include(Stamped)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stamped-0.2.1 lib/stamped.rb
stamped-0.2.0 lib/stamped.rb
stamped-0.1.0 lib/stamped.rb