Skip to content

Commit 02aec1c

Browse files
committed
Only require year in Gergorian inLeapYear method
A later commit is going to type all inLeapYear methods as only needing the year in the input, not a full date. This inLeapYear implementation is the only one where this type limitation needed a runtime change, so it's split into its own commit.
1 parent e046ccd commit 02aec1c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/calendar.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,8 +1691,11 @@ const makeHelperGregorian = (id: BuiltinCalendarId, originalEras: InputEra[]) =>
16911691
eras,
16921692
anchorEra,
16931693
calendarType: 'solar',
1694-
inLeapYear(calendarDate /*, cache */) {
1695-
const { year } = this.estimateIsoDate(calendarDate);
1694+
inLeapYear(calendarDate /*, cache: OneObjectCache */) {
1695+
// Calendars that don't override this method use the same months and leap
1696+
// years as Gregorian. Once we know the ISO year corresponding to the
1697+
// calendar year, we'll know if it's a leap year or not.
1698+
const { year } = this.estimateIsoDate({ month: 1, day: 1, year: calendarDate.year });
16961699
return isGregorianLeapYear(year);
16971700
},
16981701
monthsInYear(/* calendarDate */) {

0 commit comments

Comments
 (0)