era-without-year.js (876B)
1 // |reftest| skip-if(!this.hasOwnProperty("Intl")) 2 3 // Test using "era" option without "year" for all possible calendars. The exact 4 // formatted result is not tested, it should only be consistent with the 5 // resolved options. 6 7 const options = [ 8 { 9 era: "narrow", 10 month: "narrow", 11 }, 12 { 13 era: "short", 14 day: "numeric", 15 }, 16 { 17 era: "long", 18 hour: "2-digit", 19 }, 20 ]; 21 22 for (let calendar of Intl.supportedValuesOf("calendar")) { 23 for (let opts of options) { 24 let dtf = new Intl.DateTimeFormat("en", opts); 25 let resolved = dtf.resolvedOptions(); 26 let parts = dtf.formatToParts(0); 27 28 // Ensure there's an "era" part when the resolved options include "era". 29 assertEq( 30 parts.findIndex(p => p.type === "era") >= 0, 31 Object.hasOwn(resolved, "era") 32 ); 33 } 34 } 35 36 if (typeof reportCompare === "function") 37 reportCompare(0, 0, "ok");