1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5js> load('testsrc/doctests/util.js');
6
7js> Date.prototype.toISOString;
8function toISOString() { [native code for Date.toISOString, arity=0] }
9
10js> expectError(function() {
11  >   new Date(Infinity).toISOString()
12  > }, RangeError);
13
14js> new Date(0).toISOString()
151970-01-01T00:00:00.000Z
16
17js> var isoFormat = /(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d).(\d\d\d)Z/;
18js> var now = new Date();
19
20js> var matches = isoFormat.exec(now.toISOString());
21js> matches[0] === now.toISOString()
22true
23js> matches[1] == now.getUTCFullYear()
24true
25js> matches[2] == now.getUTCMonth()+1
26true
27js> matches[3] == now.getUTCDate()
28true
29js> matches[4] == now.getUTCHours()
30true
31js> matches[5] == now.getUTCMinutes()
32true
33js> matches[6] == now.getUTCSeconds()
34true
35js> matches[7] == now.getUTCMilliseconds()
36true
37