1// Copyright JS Foundation and other contributors, http://js.foundation 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15try { 16 d = new Date (-8640000000000001) 17 assert (d == "Invalid Date") 18 d.toISOString() 19 assert(false); 20} catch (e) { 21 assert(e instanceof RangeError) 22} 23 24assert (new Date (-8640000000000000).toISOString() == "-271821-04-20T00:00:00.000Z") 25 26assert (new Date(-62167219200001).toISOString() == "-000001-12-31T23:59:59.999Z") 27assert (new Date(-62167219200000).toISOString() == "0000-01-01T00:00:00.000Z") 28 29assert (new Date(-61851600000001).toISOString() == "0009-12-31T23:59:59.999Z") 30assert (new Date(-61851600000000).toISOString() == "0010-01-01T00:00:00.000Z") 31 32assert (new Date(-59011459200001).toISOString() == "0099-12-31T23:59:59.999Z") 33assert (new Date(-59011459200000).toISOString() == "0100-01-01T00:00:00.000Z") 34 35assert (new Date(-30610224000001).toISOString() == "0999-12-31T23:59:59.999Z") 36assert (new Date(-30610224000000).toISOString() == "1000-01-01T00:00:00.000Z") 37 38assert (new Date(-1).toISOString() == "1969-12-31T23:59:59.999Z") 39assert (new Date(0).toISOString() == "1970-01-01T00:00:00.000Z") 40assert (new Date(1).toISOString() == "1970-01-01T00:00:00.001Z") 41 42assert (new Date(253402300799999).toISOString() == "9999-12-31T23:59:59.999Z") 43assert (new Date(253402300800000).toISOString() == "+010000-01-01T00:00:00.000Z") 44 45assert (new Date (8640000000000000).toISOString() == "+275760-09-13T00:00:00.000Z") 46 47try { 48 d = new Date (8640000000000001) 49 assert (d == "Invalid Date") 50 d.toISOString() 51 assert(false); 52} catch (e) { 53 assert(e instanceof RangeError) 54} 55