es6.date.to-string.js 435 B

123456789101112
  1. var DateProto = Date.prototype;
  2. var INVALID_DATE = 'Invalid Date';
  3. var TO_STRING = 'toString';
  4. var $toString = DateProto[TO_STRING];
  5. var getTime = DateProto.getTime;
  6. if (new Date(NaN) + '' != INVALID_DATE) {
  7. require('./_redefine')(DateProto, TO_STRING, function toString() {
  8. var value = getTime.call(this);
  9. // eslint-disable-next-line no-self-compare
  10. return value === value ? $toString.call(this) : INVALID_DATE;
  11. });
  12. }