Skip to content

Instantly share code, notes, and snippets.

@JadedEvan
Created July 21, 2010 23:13
Show Gist options
  • Save JadedEvan/485282 to your computer and use it in GitHub Desktop.
Save JadedEvan/485282 to your computer and use it in GitHub Desktop.
class Numeric
def ordinal
self.to_s + ( (10...20).include?(self) ? 'th' : %w{ th st nd rd th th th th th th }[self % 10] )
end
end
@JadedEvan
Copy link
Author

Should be used on the 'day' component of the Date. DateTime.now.day.ordinal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment