getLocaleMonthNames
Signature
Section titled “Signature”getLocaleMonthNames(locale: string | string[], style?: LocaleNameStyle): string[]Return the 12 Gregorian calendar-month names for a locale, in calendar order (January first, December last — not alphabetical).
- Uses the host runtime’s
Intldata viaTemporal.PlainDate, so output depends on the runtime’s ICU build (full-ICU runtimes localize every locale; partial-ICU runtimes fall back to English). - Restricted to the Gregorian calendar; non-Gregorian calendar variants are out of scope for this function.
- A
-u-ca-subtag inlocaleis ignored. Both lookups passcalendar: "gregory"in the options bag, and ECMA-402’sResolveLocaleranks an options value above the locale extension, sogetLocaleMonthNames("en-US-u-ca-hebrew")returns the same twelve Gregorian month names asgetLocaleMonthNames("en-US"). That is deliberate — the function is Gregorian by contract — but it means the tag is accepted and overridden, not rejected. For another calendar’s names, format a date in it:formatDate("2024-03-15", "en-US-u-ca-hebrew", { month: "long" }). - Returns
[]iflocaleis not a well-formed BCP 47 tag (ECMA-402IsWellFormedLanguageTag). A well-formed tag with no matching locale data is not an error: it falls back to the host’s default locale, as ECMA-402ResolveLocalerequires.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
locale | string | string[] | BCP 47 locale tag (e.g. “en-US”, “fr-FR”, “ar-SA”), 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 [] |
style | LocaleNameStyle | Optional name style: "long" (default), "short", or "narrow" |
Returns
Section titled “Returns”12-element array of month names in calendar order, or [] on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { getLocaleMonthNames } from "@northguild/gmt/plain/locale";
getLocaleMonthNames("en-US") // ["January", "February", ... "December"]