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.

is.js 666B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. var isPrototype = require("../prototype/is");
  3. var dateValueOf = Date.prototype.valueOf;
  4. module.exports = function (value) {
  5. if (!value) return false;
  6. try {
  7. // Sanity check (reject objects which do not expose common Date interface)
  8. if (typeof value.getFullYear !== "function") return false;
  9. if (typeof value.getTimezoneOffset !== "function") return false;
  10. if (typeof value.setFullYear !== "function") return false;
  11. // Ensure its native Date object (has [[DateValue]] slot)
  12. dateValueOf.call(value);
  13. } catch (error) {
  14. return false;
  15. }
  16. // Ensure it hosts valid date
  17. if (isNaN(value)) return false;
  18. return !isPrototype(value);
  19. };