1 | 'use strict';
|
2 | var $ = require('../internals/export');
|
3 | var fails = require('../internals/fails');
|
4 | var toObject = require('../internals/to-object');
|
5 | var toPrimitive = require('../internals/to-primitive');
|
6 |
|
7 | var FORCED = fails(function () {
|
8 | return new Date(NaN).toJSON() !== null
|
9 | || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1;
|
10 | });
|
11 |
|
12 |
|
13 |
|
14 | $({ target: 'Date', proto: true, forced: FORCED }, {
|
15 |
|
16 | toJSON: function toJSON(key) {
|
17 | var O = toObject(this);
|
18 | var pv = toPrimitive(O);
|
19 | return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
|
20 | }
|
21 | });
|