Created
May 3, 2016 16:12
-
-
Save tobypinder/5ff100a6da0dac1dfbbe8aed5c6b1fa7 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
require 'date' | |
class Fixnum | |
# Via ActiveSupport | |
def ordinalize | |
if (11..13).include?(self % 100) | |
"#{self}th" | |
else | |
case self % 10 | |
when 1; "#{self}st" | |
when 2; "#{self}nd" | |
when 3; "#{self}rd" | |
else "#{self}th" | |
end | |
end | |
end | |
end | |
class Date | |
def mode7 | |
strftime("%B the #{day.ordinalize} be with you") | |
end | |
end | |
puts Date.today.mode7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment