( style: 'long' | 'short' | 'narrow', numeric: 'always' | 'auto', )
| 54 | const rtfCache = new Map<string, Intl.RelativeTimeFormat>() |
| 55 | |
| 56 | export function getRelativeTimeFormat( |
| 57 | style: 'long' | 'short' | 'narrow', |
| 58 | numeric: 'always' | 'auto', |
| 59 | ): Intl.RelativeTimeFormat { |
| 60 | const key = `${style}:${numeric}` |
| 61 | let rtf = rtfCache.get(key) |
| 62 | if (!rtf) { |
| 63 | rtf = new Intl.RelativeTimeFormat('en', { style, numeric }) |
| 64 | rtfCache.set(key, rtf) |
| 65 | } |
| 66 | return rtf |
| 67 | } |
| 68 | |
| 69 | // Timezone is constant for the process lifetime |
| 70 | let cachedTimeZone: string | null = null |
no test coverage detected