getWeekArray
Commons
stable
Builds a 2-D array of Date objects representing the calendar grid for the month containing the given date. Each inner array is one week (7 days). Padding days from adjacent months fill the first and last partial weeks.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- daterequisDate
- Any date within the target month. Only the month and year are used.
- localerequisstring
- BCP 47 locale tag used to look up the locale-specific first day of the week when firstDayOfWeek is omitted (e.g. "en-US" → Sunday, "fr-FR" → Monday).
- firstDayOfWeeknumber
- Explicit override for the first day of the week (0 = Sunday, 1 = Monday, …). When provided it takes priority over the locale lookup.
API
Valeur de retour
La valeur retournée par cet util.
- A 2-D array of Date objects. Length is 4–6 outer rows, each inner row has exactly 7 elements.
Usage
Exemples
Extraits de code prêts à coller.
Build a January 2024 calendar grid