A simple JavaScript utility to convert various values to a Date.
npm install --save qc-to_date
import { toDate, toDateOrNull } from 'qc-to_date';
toDate(946684800000); // Date on 2000-01-01T00:00:00.000 UTC
toDate(new Date()); // The Date input
// Returns the Date created from the number returned from `toDate`.
toDate({ toDate() { return 946684800000; } });
// Returns the Date returned from `toDate`.
toDate({ toDate() { return new Date(); } });
toDate(<not-date-like>); // The not-date-like input
toDate(<not-date-like>, undefined); // The not-date-like input
toDate(<not-date-like>, null); // `null`
toDate(<not-date-like>, 0); // `0`
toDate(<not-date-like>, new Date()); // The new Date
toDate(<not-date-like>, { def: {...} }); // The `{...}` object
toDateOrNull(<not-date-like>); // `null`
toDateOrNull(<date-like>); // The Date