@@ -12,6 +12,9 @@ features: [Intl.Era-monthcode]
1212
1313const multipleEraTests = [
1414 [ "gregory" , [ - 100 , 2025 ] ] ,
15+ [ "islamic-civil" , [ 600 , 2025 ] ] ,
16+ [ "islamic-tbla" , [ 600 , 2025 ] ] ,
17+ [ "islamic-umalqura" , [ 600 , 2025 ] ] ,
1518 [ "japanese" , [ - 100 , 1850 , 1880 , 1920 , 1930 , 1990 , 2025 ] ] ,
1619 [ "roc" , [ 1900 , 2025 ] ] ,
1720] ;
@@ -45,10 +48,44 @@ for (const [calendar, isoYears] of multipleEraTests) {
4548 assert . sameValue ( new Set ( eras ) . size , eras . length , `${ calendar } eras (${ eras . join ( "," ) } ) should be unique` ) ;
4649}
4750
51+ // Test that ethopic has two distinct eras and the first one encompasses both
52+ // negative and positive years
53+ {
54+ const formatter = new Intl . DateTimeFormat ( "en" , {
55+ calendar : "ethiopic" ,
56+ era : "long" ,
57+ year : "numeric" ,
58+ } ) ;
59+
60+ const eras = [ ] ;
61+
62+ for ( const isoYear of [ - 6000 , 0 , 2025 ] ) {
63+ const date = new Date ( isoYear , 5 , 15 ) ;
64+ const parts = formatter . formatToParts ( date ) ;
65+
66+ const eraPart = parts . find ( ( { type } ) => type === "era" ) ;
67+ assert . notSameValue ( eraPart , undefined , `Format of ethiopic ISO ${ isoYear } should have era part` ) ;
68+ assert . sameValue ( typeof eraPart . value , "string" , `Era format of ethiopic ISO ${ isoYear } should be a string` ) ;
69+ assert ( eraPart . value . length > 0 , `Era format of ethiopic ISO ${ isoYear } should not be empty` ) ;
70+ eras . push ( eraPart . value ) ;
71+
72+ const format = formatter . format ( date ) ;
73+ assert ( format . includes ( eraPart . value ) , `${ format } should include ${ eraPart . value } era` ) ;
74+
75+ const yearPart = parts . find ( ( { type } ) => type === "year" ) ;
76+ assert . notSameValue ( yearPart , undefined , `Format of ethiopic ISO ${ isoYear } should have year part` ) ;
77+ }
78+
79+ assert . sameValue ( eras [ 0 ] , eras [ 1 ] , "Ethiopic AA era for both positive and negative years" ) ;
80+ assert . notSameValue ( eras [ 0 ] , eras [ 2 ] , "Ethopic AA and AM eras are distinct" ) ;
81+ }
82+
83+
4884// Calendars with a single era: test one year occurring before and one after the
4985// single era's epoch
5086const singleEraTests = [
5187 [ "buddhist" , [ - 600 , 2025 ] ] ,
88+ [ "coptic" , [ 250 , 2025 ] ] ,
5289 [ "ethioaa" , [ - 5550 , 2025 ] ] ,
5390 [ "hebrew" , [ - 3800 , 2025 ] ] ,
5491 [ "indian" , [ 70 , 2025 ] ] ,
0 commit comments