isValidTimeZone
Signature
Section titled “Signature”isValidTimeZone(timeZone: string): booleanisValidTimeZone(timeZone: void | {} | null | undefined): booleanisValidTimeZone(timeZone: unknown): timeZone is stringValidate whether a string is a valid time zone identifier: an IANA name or a UTC offset.
- Uses Temporal.ZonedDateTime.from to test timezone validity.
- Uses the
timeZoneLikeregex to check the identifier’s shape: Temporal’sTimeZoneIdentifiergrammar (§13.31). - Accepts every IANA Zone and Link name the runtime accepts, including single-component names (
UTC,Japan,Zulu,EST5EDT,GMT+0), in any letter case (ECMA-402 matches identifiers ASCII-case-insensitively, soutcis as valid asamerica/new_york). - Accepts an offset identifier (
UTCOffset[~SubMinutePrecision]):"+05:00","+0530","-08", hour00–23, no seconds. Temporal andIntl.DateTimeFormataccept the same ones. - Returns false for invalid timezone formats.
- Compatibility: earlier releases required a
/in every name exceptUTCandGMT. To keep that narrower rule, also requiretimeZone.includes("/")or"UTC"/"GMT". - A stored offset with seconds (
-00:44:30) is false here and true forisValidUtcOffset. To check what a function with a zoneless result accepts, useisValidTimeZone(x) || isValidUtcOffset(x). - A value that is not a string, a
Stringobject included, returnsfalse. Atrueresult narrows anunknownvalue tostring.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
timeZone | string | any value; a string is checked as an IANA time zone identifier or a UTC offset |
Returns
Section titled “Returns”boolean indicating validity
Examples
Section titled “Examples”import { isValidTimeZone } from "@northguild/gmt/zoned/validate";
isValidTimeZone("Asia/Kolkata") // trueSource
Section titled “Source”Accessibility
© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.