Skip to content

Instantly share code, notes, and snippets.

@justinfrench
Created May 12, 2009 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinfrench/110741 to your computer and use it in GitHub Desktop.
Save justinfrench/110741 to your computer and use it in GitHub Desktop.
# http://rpheath.com/posts/409-rails-time-date-formatting-with-lambda
Time::DATE_FORMATS.merge!(
:friendly => lambda { |time|
if time.year == Time.now.year
time.strftime "%b #{time.day.ordinalize}"
else
time.strftime "%b #{time.day.ordinalize}, %Y"
end
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment