@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
20 lines (19 loc) • 572 B
JavaScript
/**
* Return the array of all available IANA timezone identifiers.
*
* - Uses `Intl.supportedValuesOf('timeZone')` to get the full list.
* - Returns `[]` when the API is unavailable (older runtimes).
*
* @returns array of IANA timezone identifier strings, or `[]` on failure
*
* @example getTimeZones() // ["America/New_York", "Europe/London", ...]
* @example getTimeZones().length // ~422 (varies by runtime/ICU)
*/
export function getTimeZones() {
try {
return Intl.supportedValuesOf("timeZone") || [];
}
catch {
return [];
}
}