Sha256: 605fe1de01e9fe599eec16fb31b12d44d001cbc1185261af5cf3cd9d478e4c03

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

class Time

  def stamp( fmt = nil )
    case fmt
    when :db, :dbase, :database, :utc
      strftime("%Y-%m-%d %H:%M:%S")
    when :short
      strftime("%e %b %H:%M")
    when :long
      strftime("%B %e, %Y %H:%M")
    when :day1st, :dmYHM  # TODO generalize
      strftime("%d-%m-%Y %H:%M")
    when String
      strftime( fmt ).strip
    else
      strftime("%a %b %d %H:%M:%S %Z %Y")
    end
  end

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'
  require 'time'

  class TCTime < Test::Unit::TestCase

    def setup
      @t = Time.parse('4/20/2005 15:37')
    end

    def test_stamp
      assert_equal( "Wed Apr 20 15:37:00 EDT 2005", @t.stamp )
    end

  end

=end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facets-0.9.0 lib/nano/time/stamp.rb
facets-1.0.0 lib/facet/time/stamp.rb