mirror of https://github.com/tc39/test262.git
Update DateTimeFormat proleptic Gregorian testing to include era (#3722)
Ref https://github.com/tc39/ecma402/issues/723
This commit is contained in:
parent
a157570ddc
commit
788bc809bf
|
@ -15,7 +15,7 @@ var dates = [
|
|||
-8640000000000000 // beginning of ECMAScript time
|
||||
];
|
||||
|
||||
var format = new Intl.DateTimeFormat(["en-US"], {year: "numeric", month: "long", timeZone: "UTC"});
|
||||
var format = new Intl.DateTimeFormat(["en-US"], {year: "numeric", era: "short", timeZone: "UTC"});
|
||||
|
||||
// this test requires a Gregorian calendar, which we usually find in the US
|
||||
assert.sameValue(format.resolvedOptions().calendar, "gregory", "Internal error: Didn't find Gregorian calendar");
|
||||
|
@ -24,6 +24,8 @@ dates.forEach(function (date) {
|
|||
var year = new Date(date).getUTCFullYear();
|
||||
var expectedYear = year <= 0 ? 1 - year : year;
|
||||
var expectedYearString = expectedYear.toLocaleString(["en-US"], {useGrouping: false});
|
||||
var expectedEra = year <= 0 ? /BC/ : /AD|(?:^|[^B])CE/;
|
||||
var dateString = format.format(date);
|
||||
assert.notSameValue(dateString.indexOf(expectedYearString), -1, "Formatted year doesn't contain expected year – expected " + expectedYearString + ", got " + dateString + ".");
|
||||
assert(expectedEra.test(dateString), "Formatted year doesn't contain expected era – expected " + expectedEra + ", got " + dateString + ".");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue