getWeeksInMonth
Signature
Section titled “Signature”getWeeksInMonth(value: string, locale: string | string[]): number | nullReturn 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 UTS #35 week of month (
W) of the month’s last day, with the locale’s first day of week and minimal days fixed at 1 (seegetWeekOfMonth). - 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 | string[] | BCP 47 locale tag (e.g. “fr-FR”, “ja-JP”, “en-US”), 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 |
Returns
Section titled “Returns”number of week-rows the month spans (4-6), or null on invalid input
Examples
Section titled “Examples”import { getWeeksInMonth } from "@northguild/gmt/plain/calculate";
getWeeksInMonth("2024-02-15", "pt-BR") // 5Source
Section titled “Source”Accessibility
© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.