parseRfc3339
Signature
Section titled “Signature”parseRfc3339(value: string): stringParse a strict RFC 3339 datetime string into a zoned ISO 8601 datetime string.
- Accepts
T,t, or a single space as the date/time separator (all three are valid RFC 3339, unlike GMT’s own zoned strings which always useT) and eitherZ/zor a numeric±HH:MMoffset. - RFC 3339 carries no IANA zone name, so the parsed offset becomes the result’s time zone identifier too (e.g.
Z→+00:00[+00:00]) — the same fixed-offset-as-zone conventionparseRfc2822uses. Zand-00:00become+00:00. RFC 9557 §2.2 (updating RFC 3339 §4.3) givesZand the older-00:00the meaning “the time in UTC is known, but the offset to local time is unknown”, unlike+00:00. A Temporal offset cannot carry that distinction, so it is lost; the instant is exact.- Rejects GMT’s own bracketed zoned strings (
...+00:00[UTC]) — that annotation is not valid RFC 3339 input; useTemporal.ZonedDateTime.from/isValidZonedDateTimedirectly for GMT’s native format instead.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | RFC 3339 datetime string (e.g. “2024-03-15T14:30:00-04:00”) |
Returns
Section titled “Returns”zoned ISO 8601 datetime string, or "" on invalid input
Examples
Section titled “Examples”import { parseRfc3339 } from "@northguild/gmt/zoned/parse";
parseRfc3339("2024-03-15T14:30:00-04:00") // "2024-03-15T14:30:00-04:00[-04:00]"