(instant: Date, timeZone: string)
| 88 | * to recover the local date/time a stored task instant represents in its zone. |
| 89 | */ |
| 90 | export function zonedWallClock(instant: Date, timeZone: string): string { |
| 91 | const parts = new Intl.DateTimeFormat('en-CA', { |
| 92 | timeZone, |
| 93 | year: 'numeric', |
| 94 | month: '2-digit', |
| 95 | day: '2-digit', |
| 96 | hour: '2-digit', |
| 97 | minute: '2-digit', |
| 98 | hourCycle: 'h23', |
| 99 | }).formatToParts(instant) |
| 100 | const get = (type: string) => parts.find((p) => p.type === type)?.value ?? '00' |
| 101 | return `${get('year')}-${get('month')}-${get('day')}T${get('hour')}:${get('minute')}` |
| 102 | } |
| 103 | |
| 104 | /** The current wall-clock time in `timeZone` as a naive `yyyy-MM-ddTHH:mm` string. */ |
| 105 | export function wallClockNow(timeZone: string): string { |
no test coverage detected