@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
29 lines • 1.73 kB
TypeScript
/**
* RegExp matching ISO 8601 local date-time (extended): `<date>T<time>`.
*
* - Date half: `YYYY-MM-DD` or `±YYYYYY-MM-DD` (6-digit year with sign, never `-000000`,
* which is a Syntax Error in Temporal's `DateYear`).
* - Time half: `HH:mm` with optional `:ss[.fffffffff]` (fractional seconds use `.` or `,`).
* - Second `60` does not match. Temporal's `TimeSecond` admits it, but GMT rejects leap
* seconds because Temporal would read one as `:59`. The 9-digit fraction cap is Temporal's
* nanosecond precision.
* - No timezone designator — this is a plain/local date-time only.
* - Shape-only validation; real calendar validation is delegated to
* `Temporal.PlainDateTime.from` in `isValidDateTime`.
*
* Capture groups: 1 month, 2 day, 3 hour. The year, minute, second and fraction are not
* captured.
*
* The written form only, with no RFC 9557 annotation. `isValidDateTime` reads more: it matches this
* against the part before the first `[` and lets Temporal read the annotations
* (`"…[u-ca=iso8601]"`, an elective `"…[foo=bar]"`).
*
* @example plainDateTime.test("2024-03-15T14:30:00") // true
* @example plainDateTime.test("2024-03-15T14:30") // true (seconds omitted)
* @example plainDateTime.test("+000031-04-30T12:00:00.123") // true (6-digit year)
* @example plainDateTime.exec("2024-03-15T14:30:45")?.slice(1) // ["03", "15", "14"] (month, day, hour)
* @example plainDateTime.test("-000000-01-01T00:00") // false (negative zero year)
* @example plainDateTime.test("2024-03-15 14:30:00") // false (space separator)
* @example plainDateTime.test("2024-03-15T14:30:00Z") // false (has timezone)
*/
export declare const plainDateTime: RegExp;