Skip to content

Commit 2e156ec

Browse files
committed
Polyfill: Make gregory calendar return undefined week numbers
This is currently unspecified behaviour, and is to be specified later in tc39/proposal-intl-era-monthcode#15 Closes: #3096
1 parent da53e9a commit 2e156ec

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

polyfill/lib/calendar.mjs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,20 @@ function arrayFromSet(src) {
7575
}
7676

7777
function calendarDateWeekOfYear(id, isoDate) {
78-
// Supports only Gregorian and ISO8601 calendar; can be updated to add support for other calendars.
78+
// Supports only ISO8601 calendar; can be updated to add support for other calendars.
7979
// Returns undefined for calendars without a well-defined week calendar system.
8080
// eslint-disable-next-line max-len
8181
// Also see: https://github.com/unicode-org/icu/blob/ab72ab1d4a3c3f9beeb7d92b0c7817ca93dfdb04/icu4c/source/i18n/calendar.cpp#L1606
82-
if (id !== 'gregory' && id !== 'iso8601') {
83-
return { week: undefined, year: undefined };
84-
}
82+
if (id !== 'iso8601') return { week: undefined, year: undefined };
8583
const calendar = impl[id];
8684
let yow = isoDate.year;
8785
const { dayOfWeek, dayOfYear, daysInYear } = calendar.isoToDate(isoDate, {
8886
dayOfWeek: true,
8987
dayOfYear: true,
9088
daysInYear: true
9189
});
92-
const fdow = id === 'iso8601' ? 1 : calendar.helper.getFirstDayOfWeek();
93-
const mdow = id === 'iso8601' ? 4 : calendar.helper.getMinimalDaysInFirstWeek();
90+
const fdow = 1;
91+
const mdow = 4;
9492

9593
// For both the input date and the first day of its calendar year, calculate the day of week
9694
// relative to first day of week in the relevant calendar (e.g., in iso8601, relative to Monday).
@@ -1687,12 +1685,6 @@ const helperGregory = ObjectAssign(
16871685
if (era === 'b') era = 'gregory-inverse';
16881686
if (era === 'a') era = 'gregory';
16891687
return { era, eraYear };
1690-
},
1691-
getFirstDayOfWeek() {
1692-
return 1;
1693-
},
1694-
getMinimalDaysInFirstWeek() {
1695-
return 1;
16961688
}
16971689
}
16981690
);

0 commit comments

Comments
 (0)