Skip to content

isValidIsoDateLike

isValidIsoDateLike(value: string): boolean

Return true when the input is a valid PlainDate or PlainDateTime ISO string.

  • Accepts both PlainDate (“2024-02-29”) and PlainDateTime (“2024-02-29T12:34:56”) formats.
  • The part before the first annotation must match plainDate or plainDateTime.
  • Reads RFC 9557 annotations as Temporal.PlainDate.from / Temporal.PlainDateTime.from do: elective ones and a time zone annotation are ignored, an unknown critical one is rejected, and the calendar must be ISO.
  • Rejects leap seconds and invalid dates/times.
ParameterTypeDescription
valuestringISO PlainDate or PlainDateTime string

boolean indicating validity

import { isValidIsoDateLike } from "@northguild/gmt/plain/validate";
isValidIsoDateLike("2024-02-29") // true
output 

plain/validate/isValidIsoDateLike.ts