This might be a bit over-engineered, but here is another Ruby solution:
defto_century(year)(year.to_i/100+1).english.ordinalendclassIntegerdefenglishEnglish::Integer.new(self)endendmoduleEnglishclassIntegerdefinitialize(integer)@value=integerend### Returns ordinal notation of the current integer ("-2nd", "1st", "312th").defordinal"#{@value}#{ordinal_suffix}"end### Returns the ordinal suffix of the current integer ("st", "nd", "rd", "th").defordinal_suffixcase@value.abs%100when1,21,31,41,51,61,71,81,91then'st'when2,22,32,42,52,62,72,82,92then'nd'when3,23,33,43,53,63,73,83,93then'rd'else'th'endendendend
This might be a bit over-engineered, but here is another Ruby solution:
Which produces the following output: