UNPKG

@technobuddha/library

Version:
14 lines (13 loc) 639 B
/** * Converts an unknown entity to a `Date` object. * * - If the entity is `null` or `undefined`, returns an invalid `Date` (`new Date(Number.NaN)`). * - If the entity is already a `Date`, returns it as is. * - If the entity is a `string` or `number`, attempts to create a `Date` from it. * - Otherwise, converts the entity to a string and creates a `Date` from that string. * @param entity - The value to convert to a `Date`. * @returns A `Date` object representing the input, or an invalid `Date` if conversion is not possible. * @group Object * @category Conversion */ export declare function toDate(entity: unknown): Date;