Skip to content

Function: prepareDate()

Call Signature

ts
function prepareDate(key: string, value: unknown, nullable: true): Date | null;

Prepares a date value for database storage with nullable support and enhanced string parsing

Parameters

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

Returns

Date | null

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

Throws

E_INVALID_PREPARED_VALUE when the value cannot be prepared

Remarks

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

Call Signature

ts
function prepareDate(key: string, value: unknown, nullable?: false): Date;

Prepares a date value for database storage with nullable support and enhanced string parsing

Parameters

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

Returns

Date

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

Throws

E_INVALID_PREPARED_VALUE when the value cannot be prepared

Remarks

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