(unit: string, mult: number, exact: boolean)
| 87 | } |
| 88 | |
| 89 | const f = (unit: string, mult: number, exact: boolean) => { |
| 90 | if (exact && ms % mult !== 0) { |
| 91 | return; |
| 92 | } |
| 93 | const v = Math.floor(ms / mult); |
| 94 | if (v > 0) { |
| 95 | r += `${v}${unit}`; |
| 96 | ms -= v * mult; |
| 97 | } |
| 98 | }; |
| 99 | |
| 100 | // Only format years and weeks if the remainder is zero, as it is often |
| 101 | // easier to read 90d than 12w6d. |
no outgoing calls