Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 592 Bytes

date.md

File metadata and controls

28 lines (19 loc) · 592 Bytes

Date

Date instance

date/is

Confirms if given object is a native date, and is not an Invalid Date

const isDate = require("type/date/is");

isDate(new Date()); // true
isDate(new Date("Invalid date")); // false
isDate(Date.now()); // false
isDate("foo"); // false

date/ensure

If given argument is a date object, it is returned back. Otherwise TypeError is thrown.

const ensureDate = require("type/date/ensure");

const date = new Date();
ensureDate(date); // date
ensureDate(123123); // Thrown TypeError: 123123 is not a date object