Created
July 1, 2010 17:26
-
-
Save alterisian/460265 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
# Convience method for ordanalized_date_string | |
def ods( date, day_of_week=false ) | |
return ordanalized_date_string( date, day_of_week ) | |
end | |
# Returns date string in format '29th December, 2009' i.e. UK style | |
# use instead of date.to_s( %stuff %rndstuff %another ) | |
def ordanalized_date_string( date, day_of_week=false ) | |
date_str = "#{date.day.ordinalize} %B, %Y" | |
if day_of_week | |
date_str = "%a " + date_str | |
end | |
return date.strftime( date_str ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I put this together as strftime doesn't have ordinalized dates in i.e 1st, 2nd, 3rd, 4th rather than 1,2,3,4
It's currently in application_helper.rb for a rails app, but probably has a more appropiate place.