Skip to content

endOfQuarterForZoned

endOfQuarterForZoned(value: string, optionsArg?: { disambiguation?: Disambiguation; offset?: Offset; fractionalSecondDigits?: FractionalDigit; }): string
import { endOfQuarterForZoned } from "@northguild/gmt/zoned/calculate";

Return the end of the quarter for a given zoned ISO datetime.

  • Calculates which quarter (1-4) the date falls into and returns the last moment of that quarter.
  • disambiguation controls DST gap/overlap resolution when a quarter boundary lands on an ambiguous local time: “compatible” (default, matches Temporal’s default), “earlier”, “later”, or “reject” (throws, resulting in “”).
  • offset controls whether the source’s existing UTC offset is kept when computing a new boundary: “prefer” (Temporal’s own default — keeps the source offset whenever still valid, which makes disambiguation inert in the (rare) common-zone case since quarter boundaries don’t fall on DST transitions), “use”, “ignore” (this function’s default — always recomputes from time zone + local time, discarding the stale offset; this is what makes disambiguation actually take effect where a quarter boundary does coincide with a transition), or “reject” (throws if the source offset is invalid for the new fields, independent of disambiguation). Leave offset at its default unless you specifically need Temporal’s raw .with() semantics.
  • fractionalSecondDigits controls how many fractional seconds are included in the output: 0 (default — no fractional seconds), 3 (milliseconds), 6 (microseconds), or 9 (nanoseconds).
  • Validation is performed on the input.
Parameter Type Description
value string ISO ZonedDateTime string

options

Option Type Default
disambiguation? Disambiguation
offset? Offset
fractionalSecondDigits? FractionalDigit

ISO ZonedDateTime string for the end of the quarter, or “” on invalid input

endOfQuarterForZoned("2024-02-15T14:30:00+00:00[UTC]") // "2024-03-31T23:59:59+00:00[UTC]"
endOfQuarterForZoned("2024-05-10T10:00:00+00:00[UTC]") // "2024-06-30T23:59:59+00:00[UTC]"
endOfQuarterForZoned("2024-11-20T08:00:00+00:00[UTC]") // "2024-12-31T23:59:59+00:00[UTC]"
endOfQuarterForZoned("2024-02-15T14:30:00+00:00[UTC]", { fractionalSecondDigits: 9 }) // "2024-03-31T23:59:59.999999999+00:00[UTC]"
endOfQuarterForZoned("invalid") // ""

zoned/calculate/endOfQuarterForZoned.ts