1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function pad(number) {
|
10 | var n = number.toString();
|
11 | return n.length === 1 ? '0' + n : n;
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function toISOString(date) {
|
23 | return date.getUTCFullYear()
|
24 | + '-' + pad(date.getUTCMonth() + 1)
|
25 | + '-' + pad(date.getUTCDate())
|
26 | + 'T' + pad(date.getUTCHours())
|
27 | + ':' + pad(date.getUTCMinutes())
|
28 | + ':' + pad(date.getUTCSeconds())
|
29 | + '.' + String((date.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5)
|
30 | + 'Z';
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | module.exports = toISOString;
|