Unless you're using Rails, add this ordinalize method (code shamelessly
lifted from the Rails source) to the Fixnum class
class Fixnum
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
Then format your date like this:
> now = Time.now
> puts now.strftime("#{now.day.ordinalize} of %B, %Y")
=> 4th of July, 2009
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…