You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
551 B

4 years ago
  1. 'use strict';
  2. var getDay = Date.prototype.getDay;
  3. var tryDateObject = function tryDateObject(value) {
  4. try {
  5. getDay.call(value);
  6. return true;
  7. } catch (e) {
  8. return false;
  9. }
  10. };
  11. var toStr = Object.prototype.toString;
  12. var dateClass = '[object Date]';
  13. var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
  14. module.exports = function isDateObject(value) {
  15. if (typeof value !== 'object' || value === null) { return false; }
  16. return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
  17. };