Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- class Fixnum
- def ordinalize
- if (11..13).include?(self % 100)
- "th"
- else
- case self % 10
- when 1; "st"
- when 2; "nd"
- when 3; "rd"
- else "th"
- end
- end
- end
- end
- # following line is broken for 11-19 (and for other cases)
- #print ["th","st","nd","rd","th","th","th","th","th","th"][Time.now.day.to_s[-1,1].to_i]
- now = Time.now
- puts now.strftime("#{now.day.ordinalize}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement