isValidRfc3339DateTime
Signature
Section titled “Signature”isValidRfc3339DateTime(value: string): booleanReturn true when value is a real RFC 3339 date-time: an ISO 8601 date and time that always states its UTC offset, as Z or ±HH:MM (RFC 3339 §5.6).
- True exactly when
parseRfc3339returns a zoned string for the same value: the validator calls the parser, so the two cannot disagree. - Checks the calendar as well as the shape. The
rfc3339DateTimepattern proves the shape alone, so it matches a day that does not exist: 29 February in a common year and 31 June are false here. - Accepts
T,tor a single space between the date and the time,Zorz, a numeric offset from-23:59to+23:59, and up to nine fraction digits. - False for a leap second (
:60), although §5.6time-secondadmits it: GMT rejects leap seconds because Temporal would read one as:59. - False for GMT’s own zoned strings, which carry a bracketed zone (
...+00:00[UTC]): that annotation is not RFC 3339. Check those withisValidZonedDateTime. - False for a non-string. Read the value with
parseRfc3339; write one withformatRfc3339.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | candidate RFC 3339 date-time string |
Returns
Section titled “Returns”boolean indicating validity
Examples
Section titled “Examples”import { isValidRfc3339DateTime } from "@northguild/gmt/zoned/validate";
isValidRfc3339DateTime("2024-03-15T14:30:00-04:00") // true