isValidZonedDateTime
Signature
Section titled “Signature”isValidZonedDateTime(value: string): booleanisValidZonedDateTime(value: void | {} | null | undefined): booleanisValidZonedDateTime(value: unknown): value is stringValidate whether a string is a valid ISO 8601 zoned datetime string.
- The part before the first annotation must be ISO 8601 extended format:
<date>T<time>, then nothing,Z, or a±HH:MM[:SS[.fraction]]offset. Basic format (20241003T143000-0400), a space or lower-casetseparator, a lower-casez, an hour-only time or offset, and a date without a time are rejected, althoughTemporal.ZonedDateTime.fromreads them. - Uses Temporal.ZonedDateTime.from for validation.
- A written offset must agree with the bracketed zone, as TC39
ToTemporalZonedDateTimematches it: an offset written to the minute may be the zone’s sub-minute offset rounded (-00:45[Africa/Monrovia]for −00:44:30, which is how Temporal writes it), and an offset written with seconds must be the zone’s offset exactly. - Rejects leap seconds.
- With an offset, the local date must be inside Temporal’s date range, as
Temporal.ZonedDateTime.fromrequires (CheckISODaysRange): a zoned string on −271821-04-19, which a zone west of Greenwich shows for the first hours of the instant range, is rejected althoughisValidInstantaccepts it. - The zone bracket is the only annotation: a calendar (
[u-ca=iso8601],[u-ca=hebrew]), an elective one ([foo=bar]), an unknown critical one or a second bracket returns false.isValidCalendarZonedDateTimereads the calendar. - Returns false for an empty string.
- A value that is not a string, a
Stringobject included, returnsfalse. Atrueresult narrows anunknownvalue tostring.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | any value; a string is checked as an ISO 8601 zoned datetime |
Returns
Section titled “Returns”boolean indicating validity
Examples
Section titled “Examples”import { isValidZonedDateTime } from "@northguild/gmt/zoned/validate";
isValidZonedDateTime("2024-02-29T12:34:56.789+00:00[UTC]") // 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.