Wrap text
Report abuse
|
|
Time::DATE_FORMATS.merge!(
:default => lambda { |time|
if time.year == Time.now.year
if time.to_date == Time.now.to_date
time.strftime("%I:%M %p").sub(/^0/, "")
else
time.strftime "%b #{time.day.ordinalize}"
end
else
time.strftime "%b #{time.day.ordinalize}, %Y"
end
},
:long => lambda { |time|
time.strftime "%B #{time.day.ordinalize}, %Y"
},
:medium => lambda { |time|
time.strftime "%b #{time.day.ordinalize}, %y"
},
:short => lambda { |time|
time.strftime "%B #{time.day.ordinalize}"
},
:time => lambda { |time|
time.strftime("%I:%M %p").sub(/^0/, "")
}
)
then call @foo.created_at in yr view and will use the :default format. @foo.created_at.to_s(:long), etc for the others.
|