qc-to_date
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

qc-to_date

Build Status Coverage Status License Downloads

npm badge

A simple JavaScript utility to convert various values to a Date.

Installation

npm install --save qc-to_date

Example Usage

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

Package Sidebar

Install

npm i qc-to_date

Weekly Downloads

2

Version

1.0.2

License

ISC

Last publish

Collaborators

  • hypersoftllc