isValidDateTime
Signature
Section titled “Signature”isValidDateTime(value: string): booleanReturn true when value is a valid PlainDateTime string.
- The part before the first annotation must match
plainDateTime. - Reads RFC 9557 annotations as
Temporal.PlainDateTime.fromdoes: elective ones ([foo=bar]) and a time zone annotation are ignored, and an unknown critical one ([!foo=bar]) is rejected. The calendar must be ISO ([u-ca=iso8601]is accepted). - Rejects leap seconds (e.g., “2024-02-29T23:59:60”).
- Rejects invalid dates (e.g., “2024-02-30”) and invalid times (e.g., “2024-02-29T24:00:00”).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | string candidate |
Returns
Section titled “Returns”boolean indicating whether the value is a valid PlainDateTime string
Examples
Section titled “Examples”import { isValidDateTime } from "@northguild/gmt/plain/validate";
isValidDateTime("2024-02-29T12:34:56") // true