es6.date.to-string.js 344 B

12345678910
  1. var DateProto = Date.prototype
  2. , INVALID_DATE = 'Invalid Date'
  3. , TO_STRING = 'toString'
  4. , $toString = DateProto[TO_STRING];
  5. if(new Date(NaN) + '' != INVALID_DATE){
  6. require('./$.redefine')(DateProto, TO_STRING, function toString(){
  7. var value = +this;
  8. return value === value ? $toString.call(this) : INVALID_DATE;
  9. });
  10. }