index.js 522 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var getDay = Date.prototype.getDay;
  3. var tryDateObject = function tryDateGetDayCall(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 = require('has-tostringtag/shams')();
  14. module.exports = function isDateObject(value) {
  15. if (typeof value !== 'object' || value === null) {
  16. return false;
  17. }
  18. return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
  19. };