Class: Time
Overview
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)
Constant Summary collapse
- DATE_FORMATS =
Helper method for string formatting Time.
{ :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" }
Instance Method Summary collapse
Instance Method Details
#to_format(key = :default) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/doozer/active_support/time.rb', line 25 def to_format(key = :default) if format = ::Time::DATE_FORMATS[key] strftime(format) else to_s end end |