js/src/tests/test262/intl402/ch12/12.1/12.1.2.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
     2 // Copyright 2012 Mozilla Corporation. All rights reserved.
     3 // This code is governed by the BSD license found in the LICENSE file.
     5 /**
     6  * @description Tests that Intl.DateTimeFormat can be subclassed.
     7  * @author Norbert Lindenberg
     8  */
    10 $INCLUDE("testIntl.js");
    12 // get a date-time format and have it format an array of dates for comparison with the subclass
    13 var locales = ["tlh", "id", "en"];
    14 var a = [new Date(0), Date.now(), new Date(Date.parse("1989-11-09T17:57:00Z"))];
    15 var referenceDateTimeFormat = new Intl.DateTimeFormat(locales);
    16 var referenceFormatted = a.map(referenceDateTimeFormat.format);
    18 function MyDateTimeFormat(locales, options) {
    19     Intl.DateTimeFormat.call(this, locales, options);
    20     // could initialize MyDateTimeFormat properties
    21 }
    23 MyDateTimeFormat.prototype = Object.create(Intl.DateTimeFormat.prototype);
    24 MyDateTimeFormat.prototype.constructor = MyDateTimeFormat;
    25 // could add methods to MyDateTimeFormat.prototype
    27 var format = new MyDateTimeFormat(locales);
    28 var actual = a.map(format.format);
    29 testArraysAreSame(referenceFormatted, actual);

mercurial