diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index 2963cd35529..b9a909e98d0 100755 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -110,7 +110,7 @@ export interface LocaleSettings {
- + {{y}}
@@ -1243,9 +1243,18 @@ export class Calendar implements OnInit,OnDestroy,ControlValueAccessor { isYearSelected(year) { if (this.isComparable()) { - let value = this.isRangeSelection() ? this.value[0] : this.value; - - return !this.isMultipleSelection() ? (value.getFullYear() === year) : false; + if (this.isMultipleSelection()) { + return false + } + else if (this.isRangeSelection()) { + if (this.value[1]) + return this.isYearEquals(this.value[0], year) || this.isYearEquals(this.value[1], year) || this.isYearBetween(this.value[0], this.value[1], year); + else + return this.isYearEquals(this.value[0], year) + } + else { + return this.isYearEquals(this.value, year); + } } return false; @@ -1268,6 +1277,22 @@ export class Calendar implements OnInit,OnDestroy,ControlValueAccessor { return between; } + isYearEquals(value, year) { + return (value && value instanceof Date && value.getFullYear() === year); + } + + isYearBetween(start, end, year) { + return start && start instanceof Date && end && end instanceof Date && start.getFullYear() <= year && end.getFullYear() >= year + } + + isLessThanMinYear(year) { + return this.minDate && year < this.minDate.getFullYear() + } + + isGreaterThanMaxYear(year) { + return this.maxDate && this.maxDate.getFullYear() < year + } + isSingleSelection(): boolean { return this.selectionMode === 'single'; }