Better date format
This commit is contained in:
10
src/math.ts
10
src/math.ts
@@ -48,3 +48,13 @@ export function fracToDec(frac: string) {
|
||||
split = (<string>split.pop()).split('/');
|
||||
return whole + (Number(split[0]) / Number(split[1]));
|
||||
}
|
||||
|
||||
export function numSuffix(num: number): string {
|
||||
if (num % 100 >= 11 && num % 100 <= 13) return `${num}th`;
|
||||
switch (num % 10) {
|
||||
case 1: return `${num}st`;
|
||||
case 2: return `${num}nd`;
|
||||
case 3: return `${num}rd`;
|
||||
default: return `${num}th`;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user