michael@0: // |reftest| fails-if(xulRuntime.OS=="WINNT") skip-if(xulRuntime.OS=="WINNT"&&isDebugBuild) 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 = 291494; michael@0: var summary = 'Date.prototype.toLocaleFormat extension'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: var temp; michael@0: michael@0: /* michael@0: * SpiderMonkey only. michael@0: * michael@0: * This test uses format strings which are not supported cross michael@0: * platform and are expected to fail on at least some platforms michael@0: * however they all currently pass on Linux (Fedora Core 6). They are michael@0: * included here in order to increase coverage for cases where a crash michael@0: * may occur. These failures will be tracked in the michael@0: * mozilla/js/tests/public-failures.txt list. michael@0: * michael@0: */ michael@0: michael@0: enterFunc ('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: var date = new Date("06/05/2005 00:00:00 GMT-0000"); michael@0: michael@0: expect = '20'; michael@0: actual = date.toLocaleFormat('%C'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%C")'); michael@0: michael@0: expect = date.toLocaleFormat('%C%y'); michael@0: actual = date.toLocaleFormat('%Y'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%C%y") == ' + michael@0: 'Date.toLocaleFormat("%Y")'); michael@0: michael@0: expect = date.toLocaleFormat('%m/%d/%y'); michael@0: actual = date.toLocaleFormat('%D'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%m/%d/%y") == ' + michael@0: 'Date.toLocaleFormat("%D")'); michael@0: michael@0: expect = (date.getTimezoneOffset() > 0) ? ' 4' : ' 5'; michael@0: actual = date.toLocaleFormat('%e'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%e")'); michael@0: michael@0: expect = date.toLocaleFormat('%Y-%m-%d'); michael@0: actual = date.toLocaleFormat('%F'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%Y-%m-%d") == ' + michael@0: 'Date.toLocaleFormat("%F")'); michael@0: michael@0: expect = '05'; michael@0: actual = date.toLocaleFormat('%g'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%g")'); michael@0: michael@0: expect = '2005'; michael@0: actual = date.toLocaleFormat('%G'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%G")'); michael@0: michael@0: expect = date.toLocaleFormat('%b'); michael@0: actual = date.toLocaleFormat('%h'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%b") == ' + michael@0: 'Date.toLocaleFormat("%h")'); michael@0: michael@0: expect = '\n'; michael@0: actual = date.toLocaleFormat('%n'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%n") == "\\n"'); michael@0: michael@0: expect = date.toLocaleFormat('%I:%M:%S %p'); michael@0: actual = date.toLocaleFormat('%r'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%I:%M:%S %p") == ' + michael@0: 'Date.toLocaleFormat("%r")'); michael@0: michael@0: expect = date.toLocaleFormat('%H:%M'); michael@0: actual = date.toLocaleFormat('%R'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%H:%M") == ' + michael@0: 'Date.toLocaleFormat("%R")'); michael@0: michael@0: expect = '\t'; michael@0: actual = date.toLocaleFormat('%t'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%t") == "\\t"'); michael@0: michael@0: expect = date.toLocaleFormat('%H:%M:%S'); michael@0: actual = date.toLocaleFormat('%T'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%H:%M:%S") == ' + michael@0: 'Date.toLocaleFormat("%T")'); michael@0: michael@0: expect = String(6 + ((date.getTimezoneOffset() > 0) ? 0 : 1)); michael@0: actual = date.toLocaleFormat('%u'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%u")'); michael@0: michael@0: expect = '22'; michael@0: actual = date.toLocaleFormat('%V'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%V")'); michael@0: michael@0: print('Note: For Date.toLocaleFormat("%m/%d/%y") == Date.toLocaleFormat("%x") ' + michael@0: 'to pass in Windows, the Regional Setting for the short date must be ' + michael@0: 'set to mm/dd/yyyy'); michael@0: expect = date.toLocaleFormat('%m/%d/%Y'); michael@0: actual = date.toLocaleFormat('%x'); michael@0: reportCompare(expect, actual, 'Date.toLocaleFormat("%m/%d/%Y") == ' + michael@0: 'Date.toLocaleFormat("%x")');