Module:Ordinalify

local p = {}

function p.Main(frame) local input = tostring(frame.args[1]) or "0" if string.len(input) > 1 then if string.sub(input, -2, -2) == "1" then return input .. "th" end end local last_char = string.sub(input, -1) if last_char == "1" then return input .. "st" elseif last_char == "2" then return input .. "nd" elseif last_char == "3" then return input .. "rd" else return input .. "th" end end

return p