Sha256: 09be4cad0f9f750faddb0747ff6fc53daf314f134df92735ac0cf5df43df8260

Contents?: true

Size: 930 Bytes

Versions: 10

Compression:

Stored size: 930 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.
  #
  #   Time.now.stamp(:short)    #=> "01 Dec 15:15"
  #
  # 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

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/time/stamp.rb
facets-2.8.3 lib/core/facets/time/stamp.rb
facets-2.8.2 lib/core/facets/time/stamp.rb
facets-2.8.1 lib/core/facets/time/stamp.rb
facets-2.8.0 lib/core/facets/time/stamp.rb
facets-2.7.0 lib/core/facets/time/stamp.rb
facets-2.6.0 lib/core/facets/time/stamp.rb
facets-2.5.0 lib/core/facets/time/stamp.rb
facets-2.5.1 lib/core/facets/time/stamp.rb
facets-2.5.2 lib/core/facets/time/stamp.rb