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 = 682754; michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: test(); michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: function iso(d) michael@0: { michael@0: return new Date(d).toISOString(); michael@0: } michael@0: michael@0: function check(s, millis){ michael@0: description = "Date.parse('"+s+"') == '"+iso(millis)+"'"; michael@0: expected = millis; michael@0: actual = Date.parse(s); michael@0: reportCompare(expected, actual, description); michael@0: } michael@0: michael@0: function checkInvalid(s) michael@0: { michael@0: description = "Date.parse('"+s+"') produces invalid date"; michael@0: expected = NaN; michael@0: actual = Date.parse(s); michael@0: reportCompare(expected, actual, description); michael@0: } michael@0: michael@0: function dd(year, month, day, hour, minute, second, millis){ michael@0: return Date.UTC(year, month-1, day, hour, minute, second, millis); michael@0: } michael@0: michael@0: function TZAtDate(d){ michael@0: return d.getTimezoneOffset() * 60000; michael@0: } michael@0: michael@0: function TZInMonth(month){ michael@0: return TZAtDate(new Date(dd(2009,month,1,0,0,0,0))); michael@0: } michael@0: michael@0: function test() michael@0: { michael@0: enterFunc ('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: michael@0: JanTZ = TZInMonth(1); michael@0: JulTZ = TZInMonth(7); michael@0: CurrTZ = TZAtDate(new Date()); michael@0: michael@0: // Allow non-standard "-0700" as timezone, not just "-07:00" michael@0: check("2009-07-23T00:53:21.001-0700", dd(2009,7,23,7,53,21,1)); michael@0: michael@0: exitFunc ('test'); michael@0: }