@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.
20 lines (18 loc) • 721 B
JavaScript
import { systemTimeZone } from "../../internal/resolveLocale.js";
// src/zoned/get/getSystemTimeZone.ts
/**
* Return the runtime system timeZone name (for example "Europe/London").
*
* - Uses Intl.DateTimeFormat().resolvedOptions().timeZone to get system timezone.
* - Returns "" when the host reports no usable time zone. With an empty `TZ` the runtime reports
* ICU's placeholder `"Etc/Unknown"`, and with an unrecognised `TZ` it reports `undefined`;
* neither is a zone that Temporal or `Intl.DateTimeFormat` accepts.
*
* @returns system timeZone name or "" on failure
*
* @example getSystemTimeZone() // "Europe/London"
*/
function getSystemTimeZone() {
return systemTimeZone();
}
export { getSystemTimeZone };