Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 // Copyright 2012 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * @description Tests that format function is bound to its Intl.DateTimeFormat.
6 * @author Norbert Lindenberg
7 */
9 $INCLUDE("testIntl.js");
11 var dates = [new Date(), new Date(0), new Date(Date.parse("1989-11-09T17:57:00Z"))];
12 var locales = [undefined, ["de"], ["th-u-ca-gregory-nu-thai"], ["en"], ["ja-u-ca-japanese"], ["ar-u-ca-islamicc-nu-arab"]];
13 var options = [
14 undefined,
15 {hour12: false},
16 {month: "long", day: "numeric", hour: "2-digit", minute: "2-digit"}
17 ];
19 locales.forEach(function (locales) {
20 options.forEach(function (options) {
21 var formatObj = new Intl.DateTimeFormat(locales, options);
22 var formatFunc = formatObj.format;
23 dates.forEach(function (date) {
24 var referenceFormatted = formatObj.format(date);
25 var formatted = formatFunc(date);
26 if (referenceFormatted !== formatted) {
27 $ERROR("format function produces different result than format method for locales " +
28 locales + "; options: " + (options ? JSON.stringify(options) : options) +
29 " : " + formatted + " vs. " + referenceFormatted + ".");
30 }
31 });
32 });
33 });