"Ordinalize" in Rails

How to display a date with suffix like “th”, “st”, “nd”, or “rd”?

for example, I wanna display like this Mon, 7th April

Rails has inbuilt function – “ordinalize”

It turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th

date.strftime("%a, #{date.day.ordinalize} %B")