Skip to content

Commit

Permalink
fix: added checking for each month when checking the disabled year
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandergu committed Oct 18, 2023
1 parent db1c1f5 commit 164f10a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/app/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1660,17 +1660,19 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor {
return false;
}

isMonthDisabled(month: number) {
for (let day = 1; day < this.getDaysCountInMonth(month, this.currentYear) + 1; day++) {
if (this.isSelectable(day, month, this.currentYear, false)) {
isMonthDisabled(month: number, year?: number) {
const yearToCheck = year ?? this.currentYear;

for (let day = 1; day < this.getDaysCountInMonth(month, yearToCheck) + 1; day++) {
if (this.isSelectable(day, month, yearToCheck, false)) {
return false;
}
}
return true;
}

isYearDisabled(year) {
return !this.isSelectable(1, this.currentMonth, year, false);
isYearDisabled(year: number) {
return Array(12).fill(0).every((v, month) => this.isMonthDisabled(month, year));
}

isYearSelected(year: number) {
Expand Down

0 comments on commit 164f10a

Please sign in to comment.