Skip to content

getWeeksInMonth

getWeeksInMonth(value: string, locale: string | string[]): number | null

Return the number of calendar-grid rows (4, 5, or 6) value’s month spans, using locale’s first day of week.

  • The count depends on which day the week starts — the same month can span 4, 5, or 6 rows depending on locale (e.g. February 2026 is 4 rows starting Sunday but 5 rows starting Monday).
  • The count is the row the month’s last day falls on, where row 1 holds the 1st (see getWeekOfMonth). This is GMT’s own rule for sizing a month grid, not a standard’s; CLDR’s minDays plays no part.
  • Comparison: @internationalized/date’s getWeeksInMonth returns the same number for the same first day of week.
  • Resolves the locale’s first day of week via Intl.Locale.prototype.weekInfo.
  • Returns null if value or locale is invalid.
ParameterTypeDescription
valuestringISO PlainDate string
localestring | string[]BCP 47 locale tag (e.g. “en-US”, “fr-FR”), or a preference list of tags (ECMA-402; the first with locale data is read). Required: omitted, or an empty list (which ECMA-402 would resolve to the host default), returns null

number of week-rows the month spans (4-6), or null on invalid input

import { getWeeksInMonth } from "@northguild/gmt/plain/calculate";
getWeeksInMonth("2024-02-15", "en-US") // 5
output 

plain/calculate/getWeeksInMonth.ts