startOfQuarterForUnix
Signature
Section titled “Signature”startOfQuarterForUnix(value: number, options?: { epochUnit?: "seconds" | "milliseconds"; timeZone?: string; disambiguation?: Disambiguation; offset?: Offset; }): numberimport { startOfQuarterForUnix } from "@northguild/gmt/unix/calculate";Return the start of the quarter for a Unix timestamp.
- Converts to ZonedDateTime, calculates quarter start, converts back to epoch.
- Q1 returns month 1, Q2 returns month 4, Q3 returns month 7, Q4 returns month 10.
disambiguationcontrols DST gap/overlap resolution when the quarter-start boundary lands on an ambiguous local time: “compatible” (default, matches Temporal’s default), “earlier”, “later”, or “reject” (throws, resulting in null).offsetcontrols whether the source’s existing UTC offset is kept when computing the new boundary: “prefer” (Temporal’s own default — keeps the source offset whenever still valid, which makesdisambiguationinert 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 ofdisambiguation). Leaveoffsetat its default unless you specifically need Temporal’s raw.with()semantics.- Returns null for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
number |
Unix timestamp (number) |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
epochUnit? |
"seconds" | "milliseconds" |
— |
timeZone? |
string |
— |
disambiguation? |
Disambiguation |
— |
offset? |
Offset |
— |
Returns
Section titled “Returns”Unix epoch number representing the start of the quarter, or null on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”startOfQuarterForUnix(1706659200000) // 1704067200000startOfQuarterForUnix(-86400000) // -25598400001 (Q1 1969 starts Jan 1)