Skip to content

Instantly share code, notes, and snippets.

@opsb
Created March 23, 2011 18:43
Show Gist options
  • Save opsb/883683 to your computer and use it in GitHub Desktop.
Save opsb/883683 to your computer and use it in GitHub Desktop.
Extend strftime with ordinalize
module StrftimeOrdinal
def self.included(base)
base.class_eval do
alias_method :old_strftime, :strftime
def strftime(format)
old_strftime format.gsub("%o", day.ordinalize)
end
end
end
end
[Time, Date].each{ |c| c.send :include, StrftimeOrdinal }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment