Skip to content

Instantly share code, notes, and snippets.

@tobypinder
Created May 3, 2016 16:12
Show Gist options
  • Save tobypinder/5ff100a6da0dac1dfbbe8aed5c6b1fa7 to your computer and use it in GitHub Desktop.
Save tobypinder/5ff100a6da0dac1dfbbe8aed5c6b1fa7 to your computer and use it in GitHub Desktop.
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