@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
21 lines (20 loc) • 585 B
JavaScript
// src/zoned/get/getTimeZones.ts
/**
* 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() // ["Africa/Abidjan", "Africa/Accra", ...]
* @example getTimeZones().length // ~422 (varies by runtime/ICU)
*/
function getTimeZones() {
try {
return Intl.supportedValuesOf("timeZone") || [];
} catch {
return [];
}
}
export { getTimeZones };