-
Notifications
You must be signed in to change notification settings - Fork 7k
/
isDate.ts
27 lines (24 loc) · 703 Bytes
/
isDate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import getTag from './.internal/getTag.js';
import isObjectLike from './isObjectLike.js';
import nodeTypes from './.internal/nodeTypes.js';
/* Node.js helper references. */
const nodeIsDate = nodeTypes && nodeTypes.isDate;
/**
* Checks if `value` is classified as a `Date` object.
*
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
* @example
*
* isDate(new Date)
* // => true
*
* isDate('Mon April 23 2012')
* // => false
*/
const isDate = nodeIsDate
? (value) => nodeIsDate(value)
: (value) => isObjectLike(value) && getTag(value) === '[object Date]';
export default isDate;