Skip to content

parseDateTime

parseDateTime<T>(spec, format?): MapSpec<T>

Defined in: extract/spec.ts:844

Parse a string value into an ISO datetime string.

Without format: validates the input as an ISO datetime and returns it as-is. With format: compiles the format string into a parser that converts the input string into an ISO datetime.

Tokens (uppercase = strict 2-digit, lowercase/single = lenient 1-2 digit):

  • YYYY (4-digit year), YY (2-digit year: <70 → 20xx, >=70 → 19xx)
  • MM/M (month), DD/D (day)
  • HH/H (hour), mm/m (minute), ss/s (second)

Produces schemaHint: { type: 'string', format: 'date-time' } for schema derivation.

T extends Spec

T

string

MapSpec<T>

// ISO validation
parseDateTime($.get('timestamp').string())
// Strict zero-padded format
parseDateTime($.get('timestamp').string(), 'MM/DD/YYYY HH:mm:ss')
// Lenient format
parseDateTime($.get('timestamp').string(), 'M/D/YY H:m:s')