Skip to content

Instantly share code, notes, and snippets.

@rufo
Created March 10, 2010 17:59
Show Gist options
  • Save rufo/328147 to your computer and use it in GitHub Desktop.
Save rufo/328147 to your computer and use it in GitHub Desktop.
>> Time.parse("3/30/2010 3:30PM").to_s(:event)
=> "Tuesday, March 30th @ 03:30 PM"
>> Time.parse("3/25/2010 3:30PM").to_s(:event)
=> "Thursday @ 03:30 PM"
EVENT_START_DATE = Time.parse("3/24/2010")
EVENT_END_DATE = Time.parse("3/29/2010")
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:event => lambda do |d|
if (d > EVENT_START_DATE) && (d < EVENT_END_DATE)
d.strftime("%A @ %I:%M %p")
else
d.strftime("%A, %B #{d.day.ordinalize} @ %I:%M %p")
end
end
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment