MCPcopy Create free account
hub / github.com/angular/components / _shouldEnableMonth

Method _shouldEnableMonth

src/material/datepicker/year-view.ts:367–397  ·  view source on GitHub ↗

Whether the given month is enabled.

(month: number)

Source from the content-addressed store, hash-verified

365
366 /** Whether the given month is enabled. */
367 private _shouldEnableMonth(month: number) {
368 const activeYear = this._dateAdapter.getYear(this.activeDate);
369
370 if (
371 month === undefined ||
372 month === null ||
373 this._isYearAndMonthAfterMaxDate(activeYear, month) ||
374 this._isYearAndMonthBeforeMinDate(activeYear, month)
375 ) {
376 return false;
377 }
378
379 if (!this.dateFilter) {
380 return true;
381 }
382
383 const firstOfMonth = this._dateAdapter.createDate(activeYear, month, 1);
384
385 // If any date in the month is enabled count the month as enabled.
386 for (
387 let date = firstOfMonth;
388 this._dateAdapter.getMonth(date) == month;
389 date = this._dateAdapter.addCalendarDays(date, 1)
390 ) {
391 if (this.dateFilter(date)) {
392 return true;
393 }
394 }
395
396 return false;
397 }
398
399 /**
400 * Tests whether the combination month/year is after this.maxDate, considering

Callers 1

_createCellForMonthMethod · 0.95

Calls 7

getYearMethod · 0.45
createDateMethod · 0.45
getMonthMethod · 0.45
addCalendarDaysMethod · 0.45
dateFilterMethod · 0.45

Tested by

no test coverage detected