Skip to content

Instantly share code, notes, and snippets.

@pkieltyka
Forked from anonymous/gist:156897
Created July 28, 2009 13:49
Show Gist options
  • Save pkieltyka/157313 to your computer and use it in GitHub Desktop.
Save pkieltyka/157313 to your computer and use it in GitHub Desktop.
def day_with_suffix(d = Time.now)
current_day = d.strftime("%d")
day_number = current_day.split(//).last
suffix = case day_number
when 1
"st"
when 2
"nd"
when 3
"rd"
else
"th"
end
return "#{current_day}#{suffix}"
end
puts day_with_suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment