UNPKG

772 BJavaScriptView Raw
1'use strict';
2// TODO: Remove from `core-js@4`
3var uncurryThis = require('../internals/function-uncurry-this');
4var defineBuiltIn = require('../internals/define-built-in');
5
6var DatePrototype = Date.prototype;
7var INVALID_DATE = 'Invalid Date';
8var TO_STRING = 'toString';
9var nativeDateToString = uncurryThis(DatePrototype[TO_STRING]);
10var thisTimeValue = uncurryThis(DatePrototype.getTime);
11
12// `Date.prototype.toString` method
13// https://tc39.es/ecma262/#sec-date.prototype.tostring
14if (String(new Date(NaN)) !== INVALID_DATE) {
15 defineBuiltIn(DatePrototype, TO_STRING, function toString() {
16 var value = thisTimeValue(this);
17 // eslint-disable-next-line no-self-compare -- NaN check
18 return value === value ? nativeDateToString(this) : INVALID_DATE;
19 });
20}