getLocaleZonedStartOfWeek
Signature
Section titled “Signature”getLocaleZonedStartOfWeek(value: string, locale: string | string[], optionsArg?: { fractionalSecondDigits?: FractionalDigit; }): stringReturn the start of the week containing value, using locale’s first day of week (e.g. en-US: Sunday, fr-FR: Monday).
- 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 the real start of the local week containing
valuein its own zone — the same kind of bucketfloorToZoneuses — so the result is never aftervalue. A week whose first midnight was skipped starts at its first real instant. - Distinct from
startOfZoned(value, "week", { weekStartsOn }), which takes an explicit ISO-biasedweekStartsOnoption instead of deriving it from a locale. - Returns "" if
valueis invalid 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 | zoned ISO 8601 datetime 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 "" |
Options
Section titled “Options”optionsArg
optional setting for the precision of the output string
| Option | Type | Default | Description |
|---|---|---|---|
fractionalSecondDigits? | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | "auto" | 8 | 9 (FractionalDigit) | 0 | The number of fractional-second digits the result is written with, 0 to 9, or "auto" to drop trailing zeros. A start has no sub-second part, so any digits written are zeros. |
Returns
Section titled “Returns”zoned ISO 8601 string for the start of value’s locale-relative week, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { getLocaleZonedStartOfWeek } from "@northguild/gmt/zoned/calculate";
getLocaleZonedStartOfWeek("2024-02-29T12:00:00+00:00[UTC]", "en-US") // "2024-02-25T00:00:00+00:00[UTC]" (Sunday)