'use strict';
var fails = require('../internals/fails');

var prototype = Date.prototype;
var getTime = prototype.getTime;
var nativeDateToISOString = prototype.toISOString;

var leadingZero = function (number) {
  return number > 9 ? number : '0' + number;
};

// `Date.prototype.toISOString` method implementation
// https://tc39.github.io/ecma262/#sec-date.prototype.toisostring
// PhantomJS / old WebKit fails here:
module.exports = (fails(function () {
  return nativeDateToISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';
}) || !fails(function () {
  nativeDateToISOString.call(new Date(NaN));
})) ? function toISOString() {
  if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');
  var date = this;
  var year = date.getUTCFullYear();
  var milliseconds = date.getUTCMilliseconds();
  var sign = year < 0 ? '-' : year > 9999 ? '+' : '';
  return sign + ('00000' + Math.abs(year)).slice(sign ? -6 : -4) +
    '-' + leadingZero(date.getUTCMonth() + 1) +
    '-' + leadingZero(date.getUTCDate()) +
    'T' + leadingZero(date.getUTCHours()) +
    ':' + leadingZero(date.getUTCMinutes()) +
    ':' + leadingZero(date.getUTCSeconds()) +
    '.' + (milliseconds > 99 ? milliseconds : '0' + leadingZero(milliseconds)) +
    'Z';
} : nativeDateToISOString;

@@ -49,16 +49,73 @@
 fails');
+%0Avar padStart = require('../internals/string-pad').start;
 %0A%0Avar pr
@@ -229,95 +229,8 @@
 g;%0A%0A
-var leadingZero = function (number) %7B%0A  return number %3E 9 ? number : '0' + number;%0A%7D;%0A%0A
 // %60
@@ -866,19 +866,17 @@
 n + 
-('00000' + 
+padStart(
 Math
@@ -889,30 +889,25 @@
 ear)
-).slice(
+, 
 sign ? 
--
 6 : 
--
 4
+, 0
 ) +%0A
@@ -912,35 +912,32 @@
 +%0A    '-' + 
-leadingZero
+padStart
 (date.getUTC
@@ -947,16 +947,22 @@
 th() + 1
+, 2, 0
 ) +%0A    
@@ -963,35 +963,32 @@
 +%0A    '-' + 
-leadingZero
+padStart
 (date.getUTC
@@ -993,16 +993,22 @@
 TCDate()
+, 2, 0
 ) +%0A    
@@ -1009,35 +1009,32 @@
 +%0A    'T' + 
-leadingZero
+padStart
 (date.getUTC
@@ -1040,16 +1040,22 @@
 CHours()
+, 2, 0
 ) +%0A    
@@ -1056,35 +1056,32 @@
 +%0A    ':' + 
-leadingZero
+padStart
 (date.getUTC
@@ -1089,16 +1089,22 @@
 inutes()
+, 2, 0
 ) +%0A    
@@ -1109,27 +1109,24 @@
   ':' + 
-leadingZero
+padStart
 (date.ge
@@ -1138,16 +1138,22 @@
 econds()
+, 2, 0
 ) +%0A    
@@ -1158,16 +1158,24 @@
   '.' + 
+padStart
 (millise
@@ -1183,62 +1183,14 @@
 onds
- %3E 99 ? milliseconds : '0' + leadingZero(milliseconds)
+, 3, 0
 ) +%0A

use `string-pad` helper in `Date#toISOString`