forked from pinks/eris
1
0
Fork 0
eris/utils/formatOrdinal.ts

8 lines
250 B
TypeScript
Raw Normal View History

2023-09-22 02:59:22 +00:00
export function formatOrdinal(n: number) {
if (n % 100 === 11 || n % 100 === 12 || n % 100 === 13) return `${n}th`;
if (n % 10 === 1) return `${n}st`;
if (n % 10 === 2) return `${n}nd`;
if (n % 10 === 3) return `${n}rd`;
return `${n}th`;
}