getWeekOfMonth
Signature
Section titled “Signature”getWeekOfMonth(value: string, locale: string): numberimport { getWeekOfMonth } from "@northguild/gmt/plain/calculate";Return the 1-based row value falls on within its month’s calendar
- grid, using
locale’s first day of week. - Week 1 is the row containing the 1st of the month, even when that row is a partial week (matches date-fns’s
getWeekOfMonth, verified against date-fns source 2026-08-21) — this is the convention every calendar-grid UI (and@internationalized/date’sgetWeeksInMonth) expects for sizing a month grid. - Distinct from ISO
weekOfYear: this counts rows within a single month’s grid, reset every month, rather than weeks since Jan 1. - Resolves the locale’s first day of week via
Intl.Locale.prototype.weekInfo. - Returns null if
valueorlocaleis invalid.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
ISO PlainDate string |
locale |
string |
BCP 47 locale tag (e.g. “en-US”, “fr-FR”) |
Returns
Section titled “Returns”1-based week-of-month row, or null on invalid input
Examples
Section titled “Examples”getWeekOfMonth("2024-02-01", "en-US") // 1getWeekOfMonth("2024-02-29", "en-US") // 5getWeekOfMonth("2026-02-01", "en-US") // 1getWeekOfMonth("2026-02-01", "en-GB") // 1getWeekOfMonth("invalid", "en-US") // null