source: trip-planner-front/node_modules/core-js/internals/date-to-iso-string.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2var fails = require('../internals/fails');
3var padStart = require('../internals/string-pad').start;
4
5var abs = Math.abs;
6var DatePrototype = Date.prototype;
7var getTime = DatePrototype.getTime;
8var nativeDateToISOString = DatePrototype.toISOString;
9
10// `Date.prototype.toISOString` method implementation
11// https://tc39.es/ecma262/#sec-date.prototype.toisostring
12// PhantomJS / old WebKit fails here:
13module.exports = (fails(function () {
14 return nativeDateToISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';
15}) || !fails(function () {
16 nativeDateToISOString.call(new Date(NaN));
17})) ? function toISOString() {
18 if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');
19 var date = this;
20 var year = date.getUTCFullYear();
21 var milliseconds = date.getUTCMilliseconds();
22 var sign = year < 0 ? '-' : year > 9999 ? '+' : '';
23 return sign + padStart(abs(year), sign ? 6 : 4, 0) +
24 '-' + padStart(date.getUTCMonth() + 1, 2, 0) +
25 '-' + padStart(date.getUTCDate(), 2, 0) +
26 'T' + padStart(date.getUTCHours(), 2, 0) +
27 ':' + padStart(date.getUTCMinutes(), 2, 0) +
28 ':' + padStart(date.getUTCSeconds(), 2, 0) +
29 '.' + padStart(milliseconds, 3, 0) +
30 'Z';
31} : nativeDateToISOString;
Note: See TracBrowser for help on using the repository browser.