getLocaleZonedEndOfWeek
Signature
Section titled “Signature”getLocaleZonedEndOfWeek(value: string, locale: string, optionsArg?: { fractionalSecondDigits?: FractionalDigit; disambiguation?: Disambiguation; offset?: Offset; }): stringimport { getLocaleZonedEndOfWeek } from "@northguild/gmt/zoned/calculate";Return the end of the week containing value, using locale’s first
- day of week (e.g. en-US: week ends Saturday, fr-FR: week ends Sunday).
- Resolves the locale’s first day of week via
Intl.Locale.prototype.weekInfo, then resets the local time-of-day to the last instant of the day. - Falls back to Monday-start (so the week ends Sunday) if the runtime’s
weekInfodata doesn’t resolve a first day for the locale. disambiguationcontrols DST gap/overlap resolution when the end-of-day reset lands on an ambiguous local time: “compatible” (default, matches Temporal’s default), “earlier”, “later”, or “reject” (throws, resulting in “”).offsetcontrols whether the source’s existing UTC offset is kept when resetting to end-of-day: “prefer” (Temporal’s own default — keeps the source offset whenever still valid, which makesdisambiguationinert for almost every case here), “use”, “ignore” (this function’s default — always recomputes from time zone + local time, discarding the stale offset; this is what makesdisambiguationactually take effect), or “reject” (throws if the source offset is invalid for the new fields, independent ofdisambiguation). Leaveoffsetat its default unless you specifically need Temporal’s raw.with()semantics.- Distinct from
endOfZoned(value, "week", { weekStartsOn }), which takes an explicit ISO-biasedweekStartsOnoption instead of deriving it from a locale. - Returns “” if
valueorlocaleis invalid.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
zoned ISO 8601 datetime string |
locale |
string |
BCP 47 locale tag (e.g. “en-US”, “fr-FR”) |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
fractionalSecondDigits? |
FractionalDigit |
— |
disambiguation? |
Disambiguation |
— |
offset? |
Offset |
— |
Returns
Section titled “Returns”zoned ISO 8601 string for the end of value’s locale-relative week, or “” on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”getLocaleZonedEndOfWeek("2024-02-29T12:00:00+00:00[UTC]", "en-US") // "2024-03-02T23:59:59+00:00[UTC]" (Saturday)getLocaleZonedEndOfWeek("2024-02-29T12:00:00+00:00[UTC]", "fr-FR") // "2024-03-03T23:59:59+00:00[UTC]" (Sunday)getLocaleZonedEndOfWeek("invalid", "en-US") // ""getLocaleZonedEndOfWeek("2024-02-29T12:00:00+00:00[UTC]", "not-a-locale") // ""