2 // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
3 var $export = require('./_export')
4 , fails = require('./_fails')
5 , getTime = Date.prototype.getTime;
7 var lz = function(num){
8 return num > 9 ? num : '0' + num;
11 // PhantomJS / old WebKit has a broken implementations
12 $export($export.P + $export.F * (fails(function(){
13 return new Date(-5e13 - 1).toISOString() != '0385-07-25T07:06:39.999Z';
14 }) || !fails(function(){
15 new Date(NaN).toISOString();
17 toISOString: function toISOString(){
18 if(!isFinite(getTime.call(this)))throw RangeError('Invalid time value');
20 , y = d.getUTCFullYear()
21 , m = d.getUTCMilliseconds()
22 , s = y < 0 ? '-' : y > 9999 ? '+' : '';
23 return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
24 '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
25 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
26 ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';