Sha256: e1d32f019647ddeff5f75925d73c42ac3e2b90985f7e14915ecbbe4ff9820f7c

Contents?: true

Size: 705 Bytes

Versions: 18

Compression:

Stored size: 705 Bytes

Contents

# Default DATE_FORMATS available
#
# Time::DATE_FORMATS.merge!({
#     :db => "%Y-%m-%d %H:%M:%S",
#     :number => "%Y%m%d%H%M%S",
#     :time => "%H:%M",
#     :mdy => "%B %d, %Y",
#     :short => "%d %b %H:%M",
#     :long => "%B %d, %Y %H:%M"
# })
# === Example Useage
# DateTime.now().to_format(:mdy)
#
class Time
  # Helper method for string formatting Time.
  DATE_FORMATS = {
      :db => "%Y-%m-%d %H:%M:%S",
      :number => "%Y%m%d%H%M%S",
      :time => "%H:%M",
      :mdy => "%B %d, %Y",
      :short => "%d %b %H:%M",
      :long => "%B %d, %Y %H:%M"
  }

  def to_format(key = :default)
    if format = ::Time::DATE_FORMATS[key]
      strftime(format)
    else
      to_s
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
grippy-doozer-0.1.0 lib/doozer/active_support/time.rb
grippy-doozer-0.1.1 lib/doozer/active_support/time.rb
grippy-doozer-0.1.2 lib/doozer/active_support/time.rb
grippy-doozer-0.1.3 lib/doozer/active_support/time.rb
grippy-doozer-0.1.4 lib/doozer/active_support/time.rb
grippy-doozer-0.1.5 lib/doozer/active_support/time.rb
doozer-0.4.4 lib/doozer/active_support/time.rb
doozer-0.4.3 lib/doozer/active_support/time.rb
doozer-0.4.2 lib/doozer/active_support/time.rb
doozer-0.4.1 lib/doozer/active_support/time.rb
doozer-0.4.0 lib/doozer/active_support/time.rb
doozer-0.3.1 lib/doozer/active_support/time.rb
doozer-0.3.0 lib/doozer/active_support/time.rb
doozer-0.2.6 lib/doozer/active_support/time.rb
doozer-0.2.5 lib/doozer/active_support/time.rb
doozer-0.2.2 lib/doozer/active_support/time.rb
doozer-0.2.1 lib/doozer/active_support/time.rb
doozer-0.2.0 lib/doozer/active_support/time.rb