getWeeksInLocaleWeekYear
Signature
Section titled “Signature”getWeeksInLocaleWeekYear(value: string, locale: string): numberimport { getWeeksInLocaleWeekYear } from "@northguild/gmt/plain/calculate";Return the number of weeks (52 or 53) in the locale week-numbering year
- containing
value, usinglocale’s first day of week and minimal-days-in-first-week. getWeeksInYear’s locale-relative counterpart — that function uses the fixed ISO rule, this one useslocale’s week-numbering rule (viaIntl.Locale.prototype.weekInfo), and the two can disagree on the same date.- Computed as the number of calendar days between the locale week-year’s start and the next week-year’s start, divided by 7 — always a whole number, since both bounds fall on the locale’s first day of week.
- 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”52 or 53, or null on invalid input
Examples
Section titled “Examples”getWeeksInLocaleWeekYear("2024-06-15", "en-US") // 52getWeeksInLocaleWeekYear("2020-06-15", "de-DE") // 53getWeeksInLocaleWeekYear("invalid", "en-US") // null