-
Notifications
You must be signed in to change notification settings - Fork 38
/
date.polyfill.js
41 lines (38 loc) · 1001 Bytes
/
date.polyfill.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
/**
* Date.prototype.toISOString()
* version 0.0.0
* Feature Chrome Firefox Internet Explorer Opera Safari Edge
* Basic support 3 1 9 10.5 5 12
* -------------------------------------------------------------------------------
*/
if (!Date.prototype.toISOString) {
Object.defineProperty(Date.prototype, 'toISOString', {
configurable: true,
writable: true,
value: function () {
function pad(number) {
if (number < 10) {
return '0' + number;
}
return number;
}
return (
this.getUTCFullYear() +
'-' +
pad(this.getUTCMonth() + 1) +
'-' +
pad(this.getUTCDate()) +
'T' +
pad(this.getUTCHours()) +
':' +
pad(this.getUTCMinutes()) +
':' +
pad(this.getUTCSeconds()) +
'.' +
(this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
'Z'
);
},
});
}