findWeekStart
Returns the first day of the week (0 = Sunday … 6 = Saturday) in a locale’s region, per CLDR: "en-US" → 0, "de-DE" → 1, "ar-EG" → 6. Accepts the same forms as the rest of d3plus: "en-US", "en_US", script tags like "sr-Latn-RS", and 2-letter language codes, which resolve to their default region through findLocale ("en" → "en-US" → 0, "ar" → "ar-SA" → 0). A locale whose region can’t be found, or anything that isn’t a string, starts on Monday (1).
The region table is static on purpose: Intl.Locale week info differs across Node 22, Node 24, and browsers, so reading it at runtime would make server-side and browser renders of the same chart disagree.
Basic example
Section titled “Basic example”Looks up the first day of the week (0 = Sunday … 6 = Saturday) for a locale’s region from a static CLDR table. Dashes and underscores both work, script subtags are skipped, and a bare language code resolves to its default region through findLocale first (en → en-US → Sunday). Anything without a known region starts on Monday.
import {findWeekStart} from "@d3plus/locales";
findWeekStart("en-US");
findWeekStart("en-GB");
findWeekStart("de_DE");
findWeekStart("ar-EG");
findWeekStart("zh-Hant-TW");
findWeekStart("en");
findWeekStart("pt");
findWeekStart("xx");
Parameters
import {findWeekStart} from "@d3plus/locales";
localerequiredstringA locale code (e.g., "en-US", "de_DE") or a 2-letter language code (e.g., "en").