
require 'date'

class Date

  # An enhanched #to_s method that cane take an optional
  # format flag of :short or :long.
  def stamp(format = nil)
    case format
    when :short
      strftime("%e %b").strip
    when :long
      strftime("%B %e, %Y").strip
    else
      strftime("%Y-%m-%d")  # standard to_s
    end
  end

end


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

  require 'test/unit'

  class TCDate < Test::Unit::TestCase

    def setup
      @d = Date.civil( 2005, 04, 20 )
    end

    def test_stamp_1
      assert_equal( "2005-04-20", @d.stamp )
    end

    def test_stamp_2
      assert_equal( "20 Apr", @d.stamp(:short) )
    end

    def test_stamp_3
      assert_equal( "April 20, 2005", @d.stamp(:long) )
    end

  end

=end
