Sha256: e8c4bc070c52a0ff862252b941b9c13f57495d1a3fd8bf827df3c6a277709b9f

Contents?: true

Size: 948 Bytes

Versions: 6

Compression:

Stored size: 948 Bytes

Contents

class Time

  unless const_defined?('FORMAT')
    FORMAT = {
      :db      => "%Y-%m-%d %H:%M:%S",
      :dbase   => "%Y-%m-%d %H:%M:%S",
      :datbase => "%Y-%m-%d %H:%M:%S",
      :utc     => "%Y-%m-%d %H:%M:%S",
      :number  => "%Y%m%d%H%M%S",
      :short   => "%d %b %H:%M",
      :time    => "%H:%M",
      :long    => "%B %d, %Y %H:%M",
      :day1st  => "%d-%m-%Y %H:%M",
      :dmYHM   => "%d-%m-%Y %H:%M",
      :rfc822  => "%a, %d %b %Y %H:%M:%S %z",
      nil      => "%a %b %d %H:%M:%S %Z %Y"
    }
  end

  # Produce time stamp for Time.now. See #stamp.
  #
  # CREDIT: Trans

  def self.stamp(*args)
    now.stamp(*args)
  end

  # Create a time stamp.
  #
  #   t = Time.at(10000)
  #   t.stamp(:short)    #=> "31 Dec 21:46"
  #
  # Supported formats come from the Time::FORMAT constant.
  #
  # CREDIT: Trans

  def stamp(fmt = nil)
    unless String === fmt
      fmt = FORMAT[fmt]
    end
    strftime(fmt).strip
  end

end

Version data entries

6 entries across 5 versions & 1 rubygems

Version Path
facets-2.9.2 lib/core/facets/time/stamp.rb
facets-2.9.2 src/core/facets/time/stamp.rb
facets-2.9.1 lib/core/facets/time/stamp.rb
facets-2.9.0 lib/core/facets/time/stamp.rb
facets-2.9.0.pre.2 lib/core/facets/time/stamp.rb
facets-2.9.0.pre.1 lib/core/facets/time/stamp.rb