tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

toString-localized.js (3597B)


      1 // |reftest| skip-if(winWidget||!this.hasOwnProperty("Intl")) -- Windows doesn't accept IANA names for the TZ env variable; Requires ICU time zone support
      2 
      3 // Date.prototype.toString includes a localized time zone name comment.
      4 
      5 inTimeZone("Europe/Paris", () => {
      6    let dt = new Date(2018, Month.July, 14);
      7 
      8    withLocale("en", () => {
      9        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0200 (Central European Summer Time)");
     10    });
     11    withLocale("fr", () => {
     12        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0200 (heure d’été d’Europe centrale)");
     13    });
     14    withLocale("de", () => {
     15        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)");
     16    });
     17    withLocale("ar", () => {
     18        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0200 (توقيت وسط أوروبا الصيفي)");
     19    });
     20    withLocale("zh", () => {
     21        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0200 (中欧夏令时间)");
     22    });
     23 });
     24 
     25 inTimeZone("America/Los_Angeles", () => {
     26    let dt = new Date(2018, Month.July, 14);
     27 
     28    withLocale("en", () => {
     29        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT-0700 (Pacific Daylight Time)");
     30    });
     31    withLocale("fr", () => {
     32        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT-0700 (heure d’été du Pacifique nord-américain)");
     33    });
     34    withLocale("de", () => {
     35        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT-0700 (Nordamerikanische Westküsten-Sommerzeit)");
     36    });
     37    withLocale("ar", () => {
     38        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT-0700 (توقيت المحيط الهادي الصيفي)");
     39    });
     40    withLocale("zh", () => {
     41        assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT-0700 (北美太平洋夏令时间)");
     42    });
     43 });
     44 
     45 for (let tz of ["UTC", "UCT", "Zulu", "Universal", "Etc/UTC", "Etc/UCT", "Etc/Zulu", "Etc/Universal"]) {
     46    inTimeZone(tz, () => {
     47        let dt = new Date(2018, Month.July, 14);
     48 
     49        withLocale("en", () => {
     50            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (Coordinated Universal Time)");
     51        });
     52        withLocale("fr", () => {
     53            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (temps universel coordonné)");
     54        });
     55        withLocale("de", () => {
     56            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (Koordinierte Weltzeit)");
     57        });
     58        withLocale("ar", () => {
     59            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (التوقيت العالمي المنسق)");
     60        });
     61        withLocale("zh", () => {
     62            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (协调世界时)");
     63        });
     64    });
     65 }
     66 
     67 for (let tz of ["GMT", "Etc/GMT"]) {
     68    inTimeZone(tz, () => {
     69        let dt = new Date(2018, Month.July, 14);
     70 
     71        withLocale("en", () => {
     72            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (Greenwich Mean Time)");
     73        });
     74        withLocale("fr", () => {
     75            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (heure moyenne de Greenwich)");
     76        });
     77        withLocale("de", () => {
     78            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (Mittlere Greenwich-Zeit)");
     79        });
     80        withLocale("ar", () => {
     81            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (توقيت غرينتش)");
     82        });
     83        withLocale("zh", () => {
     84            assertDateTime(dt, "Sat Jul 14 2018 00:00:00 GMT+0000 (格林尼治标准时间)");
     85        });
     86    });
     87 }
     88 
     89 if (typeof reportCompare === "function")
     90    reportCompare(true, true);