blob: 285ec4c2e77eb8eb6f33a5b1e04400ed894d18ec [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var getDay = Date.prototype.getDay;
4var tryDateObject = function tryDateGetDayCall(value) {
5 try {
6 getDay.call(value);
7 return true;
8 } catch (e) {
9 return false;
10 }
11};
12
13var toStr = Object.prototype.toString;
14var dateClass = '[object Date]';
15var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
16
17module.exports = function isDateObject(value) {
18 if (typeof value !== 'object' || value === null) {
19 return false;
20 }
21 return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
22};