( timeZone: string, date: Date, format: TZNameFormat = "long", )
| 27 | * @returns Time zone name (e.g. "Singapore Standard Time") |
| 28 | */ |
| 29 | export function tzName( |
| 30 | timeZone: string, |
| 31 | date: Date, |
| 32 | format: TZNameFormat = "long", |
| 33 | ): string { |
| 34 | return new Intl.DateTimeFormat("en-US", { |
| 35 | // Enforces engine to render the time. Without the option JavaScriptCore omits it. |
| 36 | hour: "numeric", |
| 37 | timeZone: timeZone, |
| 38 | timeZoneName: format, |
| 39 | }) |
| 40 | .format(date) |
| 41 | .split(/\s/g) // Format.JS uses non-breaking spaces |
| 42 | .slice(2) // Skip the hour and AM/PM parts |
| 43 | .join(" "); |
| 44 | } |
no outgoing calls
no test coverage detected