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

1.0.1 • Public • Published

qc-to_immutable_date

Build Status Coverage Status License Downloads

npm badge

A simple JavaScript utility to convert various values to an ImmutableDate.

Installation

npm install --save qc-to_immutable_date

or

yarn add qc-to_immutable_date

Example Usage

import { toImmutableDate, toImmutableDateOrNull } from 'qc-to_immutable_date';
 
toImmutableDate(946684800000);   // Date on 2000-01-01T00:00:00.000 UTC
toImmutableDate(new Date());     // The Date input
 
// Returns the Date created from the number returned from `toDate`.
toImmutableDate({ toDate() { return 946684800000; } });
 
// Returns the Date returned from `toDate`.
toImmutableDate({ toDate() { return new Date(); } });
 
toImmutableDate(<not-date-like>);                   // The not-date-like input
toImmutableDate(<not-date-like>, undefined);        // The not-date-like input
toImmutableDate(<not-date-like>, null);             // `null`
toImmutableDate(<not-date-like>, 0);                // `0`
toImmutableDate(<not-date-like>, new Date());       // The new Date
toImmutableDate(<not-date-like>, { def: {...} });   // The `{...}` object
toImmutableDateOrNull(<not-date-like>);             // `null`
toImmutableDateOrNull(<date-like>);                 // The Date

Package Sidebar

Install

npm i qc-to_immutable_date

Weekly Downloads

2

Version

1.0.1

License

ISC

Last publish

Collaborators

  • hypersoftllc