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

Method _createWeekCells

src/material/datepicker/month-view.ts:516–547  ·  view source on GitHub ↗

Creates MatCalendarCells for the dates in this month.

()

Source from the content-addressed store, hash-verified

514
515 /** Creates MatCalendarCells for the dates in this month. */
516 private _createWeekCells() {
517 const daysInMonth = this._dateAdapter.getNumDaysInMonth(this.activeDate);
518 const dateNames = this._dateAdapter.getDateNames();
519 const weeks: MatCalendarCell[][] = [[]];
520 for (let i = 0, cell = this._firstWeekOffset(); i < daysInMonth; i++, cell++) {
521 if (cell == DAYS_PER_WEEK) {
522 weeks.push([]);
523 cell = 0;
524 }
525 const date = this._dateAdapter.createDate(
526 this._dateAdapter.getYear(this.activeDate),
527 this._dateAdapter.getMonth(this.activeDate),
528 i + 1,
529 );
530 const enabled = this._shouldEnableDate(date);
531 const ariaLabel = this._dateAdapter.format(date, this._dateFormats.display.dateA11yLabel);
532 const cellClasses = this.dateClass ? this.dateClass(date, 'month') : undefined;
533
534 weeks[weeks.length - 1].push(
535 new MatCalendarCell<D>(
536 i + 1,
537 dateNames[i],
538 ariaLabel,
539 enabled,
540 cellClasses,
541 this._getCellCompareValue(date)!,
542 date,
543 ),
544 );
545 }
546 this._weeks.set(weeks);
547 }
548
549 /** Date filter for the month */
550 private _shouldEnableDate(date: D): boolean {

Callers 1

_initMethod · 0.95

Calls 10

_shouldEnableDateMethod · 0.95
_getCellCompareValueMethod · 0.95
setMethod · 0.80
pushMethod · 0.65
getNumDaysInMonthMethod · 0.45
getDateNamesMethod · 0.45
createDateMethod · 0.45
getYearMethod · 0.45
getMonthMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected