getLocaleDayOfWeek
Signature
Section titled “Signature”getLocaleDayOfWeek(value: string, locale: string): numberimport { getLocaleDayOfWeek } from "@northguild/gmt/plain/calculate";Return 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 unresolvable.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
ISO 8601 date string |
locale |
string |
BCP 47 locale tag (e.g. “en-US”, “fr-FR”) |
Returns
Section titled “Returns”locale-relative day-of-week index (0–6) or null on invalid input
Examples
Section titled “Examples”getLocaleDayOfWeek("2024-02-25", "en-US") // 0 (Sunday)getLocaleDayOfWeek("2024-02-26", "en-US") // 1 (Monday)getLocaleDayOfWeek("2024-02-26", "fr-FR") // 0 (Monday)getLocaleDayOfWeek("invalid-date", "en-US") // nullgetLocaleDayOfWeek("2024-02-29", "not-a-locale") // null