Skip to content

Commit 788bc80

Browse files
authored
Update DateTimeFormat proleptic Gregorian testing to include era (#3722)
Ref tc39/ecma402#723
1 parent a157570 commit 788bc80

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/intl402/DateTimeFormat/prototype/format/proleptic-gregorian-calendar.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var dates = [
1515
-8640000000000000 // beginning of ECMAScript time
1616
];
1717

18-
var format = new Intl.DateTimeFormat(["en-US"], {year: "numeric", month: "long", timeZone: "UTC"});
18+
var format = new Intl.DateTimeFormat(["en-US"], {year: "numeric", era: "short", timeZone: "UTC"});
1919

2020
// this test requires a Gregorian calendar, which we usually find in the US
2121
assert.sameValue(format.resolvedOptions().calendar, "gregory", "Internal error: Didn't find Gregorian calendar");
@@ -24,6 +24,8 @@ dates.forEach(function (date) {
2424
var year = new Date(date).getUTCFullYear();
2525
var expectedYear = year <= 0 ? 1 - year : year;
2626
var expectedYearString = expectedYear.toLocaleString(["en-US"], {useGrouping: false});
27+
var expectedEra = year <= 0 ? /BC/ : /AD|(?:^|[^B])CE/;
2728
var dateString = format.format(date);
2829
assert.notSameValue(dateString.indexOf(expectedYearString), -1, "Formatted year doesn't contain expected year – expected " + expectedYearString + ", got " + dateString + ".");
30+
assert(expectedEra.test(dateString), "Formatted year doesn't contain expected era – expected " + expectedEra + ", got " + dateString + ".");
2931
});

0 commit comments

Comments
 (0)