buildMonthMatrix

Calendar
stable

Build a fixed 6-row × 7-column date matrix for the month containing the given date. The grid always has exactly 6 rows so the calendar height stays stable when navigating month-to-month.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

date
required
Date
Any date inside the target month. Day precision is used to determine the first day of the month.
firstDayOfWeek
required
number
The index of the first weekday column: 0 = Sunday, 1 = Monday, … 6 = Saturday. Controls how the grid is anchored.

API

Return value

The value returned by this util.

A 6×7 nested array of Date objects covering the visible weeks. Dates from the previous and next month fill the padding rows.

Usage

Examples

Ready-to-paste usage snippets.

Generate a January 2024 grid (Monday start)

typescript