Created
March 10, 2010 17:59
-
-
Save rufo/328147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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