Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion polyfill/lib/calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ const nonIsoHelperBase = {
}
const diffYears = calendarTwo.year - calendarOne.year;
const diffDays = calendarTwo.day - calendarOne.day;
if (largestUnit === 'year' && diffYears) {
if (diffYears && (largestUnit === 'year' || !monthCodeInfo[this.id]?.additionalMonths)) {
let diffInYearSign = 0;
if (calendarTwo.monthCode > calendarOne.monthCode) diffInYearSign = 1;
if (calendarTwo.monthCode < calendarOne.monthCode) diffInYearSign = -1;
Expand All @@ -1022,6 +1022,10 @@ const nonIsoHelperBase = {
years = isOneFurtherInYear ? diffYears - sign : diffYears;
}
const yearsAdded = years ? this.addCalendar(calendarOne, { years }, 'constrain', cache) : calendarOne;
if (years && largestUnit === 'month') {
months += years * 12;
years = 0;
}
// Now we have less than one year remaining. Add one month at a time
// until we go over the target, then back up one month and calculate
// remaining days and weeks.
Expand Down