getLocaleWeekdayNames
Signature
Section titled “Signature”getLocaleWeekdayNames(locale: string | string[], style?: LocaleNameStyle): string[]Return the 7 weekday names for a locale, ordered starting from the locale’s first day of the week.
- The order is the locale’s first day of the week, never its weekend. For
en-USandar-SAthe array starts with Sunday, forfr-FRwith Monday, forar-EGwith Saturday — matching GMT’s existing locale-first-day convention ingetLocaleDayOfWeek/getLocaleStartOfWeek.ar-SA’s weekend is Friday and Saturday (new Intl.Locale("ar-SA").getWeekInfo()is{ firstDay: 7, weekend: [5, 6] }), but its week still begins on Sunday; a locale’s weekend says nothing about where its week starts. - This ordering is consistent with
getLocaleDayOfWeek: for any valid date,getLocaleWeekdayNames(locale)[getLocaleDayOfWeek(date, locale)]is that date’s localized weekday name. - Uses the host runtime’s
Intldata viaTemporal.PlainDate, so output depends on the runtime’s ICU build. - 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”7-element array of weekday names from the locale’s first day, or [] on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { getLocaleWeekdayNames } from "@northguild/gmt/plain/locale";
getLocaleWeekdayNames("en-US") // ["Sunday", "Monday", ... "Saturday"]