getLocaleDayOfWeek
Signature
Section titled “Signature”getLocaleDayOfWeek(value: string, locale: string | string[]): number | nullReturn the locale-relative day-of-week index for value.
0= the locale’s first day of week (e.g. Sunday for en-US, Monday for fr-FR).- Resolves the locale’s first day of week via
Intl.Locale.prototype.weekInfo. - Falls back to Monday if the runtime’s
weekInfodata doesn’t resolve a first day for the locale. - Returns
nullifvalueis not a valid ISO date orlocaleis 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 |
|---|---|---|
value | string | ISO 8601 date string |
locale | string | 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 |
Returns
Section titled “Returns”locale-relative day-of-week index (0–6) or null on invalid input
Examples
Section titled “Examples”import { getLocaleDayOfWeek } from "@northguild/gmt/plain/calculate";
getLocaleDayOfWeek("2024-02-25", "en-US") // 0 (Sunday)