parseDate
parseDate<
T>(spec,format?):MapSpec<T>
Defined in: extract/spec.ts:809
Parse a string value into an ISO date string (YYYY-MM-DD).
Without format: validates the input as an ISO date and returns it as-is.
With format: compiles the format string into a parser that converts the
input string into an ISO date.
Tokens (uppercase = strict 2-digit, lowercase/single = lenient 1-2 digit):
YYYY(4-digit year),YY(2-digit year: <70 → 20xx, >=70 → 19xx)MM(zero-padded month),M(1-2 digit month)DD(zero-padded day),D(1-2 digit day)
Produces schemaHint: { type: 'string', format: 'date' } for schema derivation.
Type Parameters
Section titled “Type Parameters”T extends Spec
Parameters
Section titled “Parameters”T
format?
Section titled “format?”string
Returns
Section titled “Returns”MapSpec<T>
Example
Section titled “Example”// ISO validationparseDate($.get('date').string())
// Strict zero-padded formatparseDate($.get('date').string(), 'MM/DD/YYYY')
// Lenient format (handles "10/1/21")parseDate($.get('date').string(), 'M/D/YY')
// With fallbacktryExtract(parseDate($.get('date').string(), 'M/D/YY'), literal(null))