Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hypersoftllc/qc-to_date
A simple JavaScript utility to convert various value to a Date.
https://github.com/hypersoftllc/qc-to_date
javascript-utility
Last synced: 28 days ago
JSON representation
A simple JavaScript utility to convert various value to a Date.
- Host: GitHub
- URL: https://github.com/hypersoftllc/qc-to_date
- Owner: hypersoftllc
- License: isc
- Created: 2017-05-03T22:15:51.000Z (almost 8 years ago)
- Default Branch: develop
- Last Pushed: 2017-09-11T18:32:42.000Z (over 7 years ago)
- Last Synced: 2024-12-02T11:41:51.697Z (2 months ago)
- Topics: javascript-utility
- Language: TypeScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# qc-to_date
[![Build Status][travis-svg]][travis-url]
[![Coverage Status][coverage-image]][coverage-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url][![npm badge][npm-badge-png]][package-url]
A simple JavaScript utility to convert various values to a Date.
## Installation
```sh
npm install --save qc-to_date
```## Example Usage
```js
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(); // The not-date-like input
toDate(, undefined); // The not-date-like input
toDate(, null); // `null`
toDate(, 0); // `0`
toDate(, new Date()); // The new Date
toDate(, { def: {...} }); // The `{...}` object
toDateOrNull(); // `null`
toDateOrNull(); // The Date
```[coverage-image]: https://coveralls.io/repos/github/hypersoftllc/qc-to_date/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/hypersoftllc/qc-to_date?branch=master
[downloads-image]: http://img.shields.io/npm/dm/qc-to_date.svg
[downloads-url]: http://npm-stat.com/charts.html?package=qc-to_date
[license-image]: http://img.shields.io/npm/l/qc-to_date.svg
[license-url]: LICENSE
[package-url]: https://npmjs.org/package/qc-to_date
[npm-badge-png]: https://nodei.co/npm/qc-to_date.png?downloads=true&stars=true
[travis-svg]: https://travis-ci.org/hypersoftllc/qc-to_date.svg?branch=master
[travis-url]: https://travis-ci.org/hypersoftllc/qc-to_date