Skip to content

endOfQuarterForUnix

endOfQuarterForUnix(value: number, options?: { epochUnit?: "seconds" | "milliseconds"; timeZone?: string; disambiguation?: Disambiguation; offset?: Offset; }): number
import { endOfQuarterForUnix } from "@northguild/gmt/unix/calculate";

Return the end of the quarter for a Unix timestamp.

  • Converts to ZonedDateTime, calculates quarter end, converts back to epoch.
  • Q1 ends month 3, Q2 ends month 6, Q3 ends month 9, Q4 ends month 12.
  • 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 null).
  • 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), 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.
  • Returns null for invalid input.
Parameter Type Description
value number Unix timestamp (number)

options

Option Type Default
epochUnit? "seconds" | "milliseconds"
timeZone? string
disambiguation? Disambiguation
offset? Offset

Unix epoch number representing the end of the quarter, or null on invalid input

endOfQuarterForUnix(1706659200000) // 1711977599999
endOfQuarterForUnix(-86400000) // -1 (Q4 1969 ends Dec 31)

unix/calculate/endOfQuarterForUnix.ts