1 | import isObjectLike from './isObjectLike';
|
2 |
|
3 | /** `Object#toString` result references. */
|
4 | var dateTag = '[object Date]';
|
5 |
|
6 | /** Used for built-in method references. */
|
7 | var objectProto = Object.prototype;
|
8 |
|
9 | /**
|
10 | * Used to resolve the
|
11 | * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
12 | * of values.
|
13 | */
|
14 | var objectToString = objectProto.toString;
|
15 |
|
16 | /**
|
17 | * Checks if `value` is classified as a `Date` object.
|
18 | *
|
19 | * @static
|
20 | * @memberOf _
|
21 | * @since 0.1.0
|
22 | * @category Lang
|
23 | * @param {*} value The value to check.
|
24 | * @returns {boolean} Returns `true` if `value` is correctly classified,
|
25 | * else `false`.
|
26 | * @example
|
27 | *
|
28 | * _.isDate(new Date);
|
29 | * // => true
|
30 | *
|
31 | * _.isDate('Mon April 23 2012');
|
32 | * // => false
|
33 | */
|
34 | function isDate(value) {
|
35 | return isObjectLike(value) && objectToString.call(value) == dateTag;
|
36 | }
|
37 |
|
38 | export default isDate;
|