Skip to content

getWeekOfMonth

getWeekOfMonth(value: string, locale: string): number
import { 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’s getWeeksInMonth) 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 value or locale is invalid.
Parameter Type Description
value string ISO PlainDate string
locale string BCP 47 locale tag (e.g. “en-US”, “fr-FR”)

1-based week-of-month row, or null on invalid input

getWeekOfMonth("2024-02-01", "en-US") // 1
getWeekOfMonth("2024-02-29", "en-US") // 5
getWeekOfMonth("2026-02-01", "en-US") // 1
getWeekOfMonth("2026-02-01", "en-GB") // 1
getWeekOfMonth("invalid", "en-US") // null

plain/calculate/getWeekOfMonth.ts