Skip to content

Function: consumeDate() ​

Call Signature ​

ts
function consumeDate(
  key: string,
  value: unknown,
  nullable: true,
): DateTime<boolean> | null;

Consumes a date value from database results with nullable support and enhanced string parsing

Parameters ​

ParameterTypeDescription
keystringThe field name for error reporting
valueunknownThe value to consume
nullabletrueWhether the field can be null

Returns ​

| DateTime<boolean> | null

The consumed DateTime value or null if nullable and value is null

Throws ​

E_INVALID_CONSUMED_VALUE when the value cannot be consumed

Remarks ​

For string values, attempts SQL format parsing first, then falls back to ISO format parsing

Call Signature ​

ts
function consumeDate(key: string, value: unknown, nullable?: false): DateTime;

Consumes a date value from database results with nullable support and enhanced string parsing

Parameters ​

ParameterTypeDescription
keystringThe field name for error reporting
valueunknownThe value to consume
nullable?falseWhether the field can be null

Returns ​

DateTime

The consumed DateTime value or null if nullable and value is null

Throws ​

E_INVALID_CONSUMED_VALUE when the value cannot be consumed

Remarks ​

For string values, attempts SQL format parsing first, then falls back to ISO format parsing