Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 65661x 65661x 141x 141x 141x | import { AbstractDataType } from './abstract-data-type.ts';
/**
* `TIMESTAMP WITH TIME ZONE` (`DataTypes.DATE`); values are `Date` objects.
*
* @internal
*/
export class DateType extends AbstractDataType {
/** Converts a driver string into a `Date`. */
readonly parse = (value: unknown): unknown =>
typeof value === 'string' ? new Date(value) : value;
/**
* @param fsp - Fractional seconds precision.
*/
/** Arguments the type was created with (v6 `options`). */
readonly options: Readonly<{ length?: string | number }>;
constructor(fsp?: number) {
super(
'DATE',
fsp === undefined
? 'TIMESTAMP WITH TIME ZONE'
: `TIMESTAMP(${AbstractDataType.integer('DATE precision', fsp)}) WITH TIME ZONE`,
);
this.options = Object.freeze(fsp === undefined ? {} : { length: fsp });
Object.freeze(this);
}
}
|