michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 301738; michael@0: var summary = 'Date parse compatibilty with MSIE'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: /* michael@0: Case 1. The input string contains an English month name. michael@0: The form of the string can be month f l, or f month l, or michael@0: f l month which each evaluate to the same date. michael@0: If f and l are both greater than or equal to 70, or michael@0: both less than 70, the date is invalid. michael@0: The year is taken to be the greater of the values f, l. michael@0: If the year is greater than or equal to 70 and less than 100, michael@0: it is considered to be the number of years after 1900. michael@0: */ michael@0: michael@0: var month = 'January'; michael@0: var f; michael@0: var l; michael@0: michael@0: f = l = 0; michael@0: expect = true; michael@0: michael@0: actual = isNaN(new Date(month + ' ' + f + ' ' + l)); michael@0: reportCompare(expect, actual, 'January 0 0 is invalid'); michael@0: michael@0: actual = isNaN(new Date(f + ' ' + l + ' ' + month)); michael@0: reportCompare(expect, actual, '0 0 January is invalid'); michael@0: michael@0: actual = isNaN(new Date(f + ' ' + month + ' ' + l)); michael@0: reportCompare(expect, actual, '0 January 0 is invalid'); michael@0: michael@0: f = l = 70; michael@0: michael@0: actual = isNaN(new Date(month + ' ' + f + ' ' + l)); michael@0: reportCompare(expect, actual, 'January 70 70 is invalid'); michael@0: michael@0: actual = isNaN(new Date(f + ' ' + l + ' ' + month)); michael@0: reportCompare(expect, actual, '70 70 January is invalid'); michael@0: michael@0: actual = isNaN(new Date(f + ' ' + month + ' ' + l)); michael@0: reportCompare(expect, actual, '70 January 70 is invalid'); michael@0: michael@0: f = 100; michael@0: l = 15; michael@0: michael@0: // year, month, day michael@0: expect = new Date(f, 0, l).toString(); michael@0: michael@0: actual = new Date(month + ' ' + f + ' ' + l).toString(); michael@0: reportCompare(expect, actual, 'month f l'); michael@0: michael@0: actual = new Date(f + ' ' + l + ' ' + month).toString(); michael@0: reportCompare(expect, actual, 'f l month'); michael@0: michael@0: actual = new Date(f + ' ' + month + ' ' + l).toString(); michael@0: reportCompare(expect, actual, 'f month l'); michael@0: michael@0: f = 80; michael@0: l = 15; michael@0: michael@0: // year, month, day michael@0: expect = (new Date(f, 0, l)).toString(); michael@0: michael@0: actual = (new Date(month + ' ' + f + ' ' + l)).toString(); michael@0: reportCompare(expect, actual, 'month f l'); michael@0: michael@0: actual = (new Date(f + ' ' + l + ' ' + month)).toString(); michael@0: reportCompare(expect, actual, 'f l month'); michael@0: michael@0: actual = (new Date(f + ' ' + month + ' ' + l)).toString(); michael@0: reportCompare(expect, actual, 'f month l'); michael@0: michael@0: f = 2040; michael@0: l = 15; michael@0: michael@0: // year, month, day michael@0: expect = (new Date(f, 0, l)).toString(); michael@0: michael@0: actual = (new Date(month + ' ' + f + ' ' + l)).toString(); michael@0: reportCompare(expect, actual, 'month f l'); michael@0: michael@0: actual = (new Date(f + ' ' + l + ' ' + month)).toString(); michael@0: reportCompare(expect, actual, 'f l month'); michael@0: michael@0: actual = (new Date(f + ' ' + month + ' ' + l)).toString(); michael@0: reportCompare(expect, actual, 'f month l'); michael@0: