reset-time-zone-cache-same-offset.js (1082B)
1 // |reftest| skip-if(winWidget||!this.hasOwnProperty('Intl')) -- Windows doesn't accept IANA names for the TZ env variable 2 3 const testCases = [ 4 { 5 timeZone: "Europe/London", 6 string: "Tue Aug 14 2018 00:00:00 GMT+0100 (BST)", 7 alternativeTimeZones: ["British Summer Time"], 8 localeString: "8/14/2018, 12:00:00 AM GMT+1", 9 }, 10 { 11 timeZone: "UTC", 12 string: "Tue Aug 14 2018 00:00:00 GMT+0000 (UTC)", 13 alternativeTimeZones: ["Coordinated Universal Time"], 14 localeString: "8/14/2018, 12:00:00 AM UTC", 15 }, 16 ]; 17 18 // Repeat twice to test both transitions (Europe/London -> UTC and UTC -> Europe/London). 19 for (let i = 0; i < 2; ++i) { 20 for (let {timeZone, string, localeString, alternativeTimeZones} of testCases) { 21 setTimeZone(timeZone); 22 23 let dt = new Date(2018, 8 - 1, 14); 24 assertDateTime(dt, string, ...alternativeTimeZones); 25 assertEq(dt.toLocaleString("en-US", {timeZoneName: "short"}), localeString); 26 } 27 } 28 29 if (typeof reportCompare === "function") 30 reportCompare(true, true);