endOfQuarterForUnix
Signature
Section titled “Signature”endOfQuarterForUnix(value: string | number, options?: { epochUnit?: UnixUnit; timeZone?: string; }): number | nullReturn 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.
- Returns the last millisecond before the next local quarter starts in
timeZone(seefloorToZone), so the result is never beforevalue: a quarter whose last local hour repeats (Africa/Cairo, 2010-09-30) ends with the second pass. - Takes no
disambiguationoroffset: a boundary is always a real instant, as TC39’sstartOfDay()takes neither. Those ignored options were removed in 1.16.0. - Returns null for invalid input.
valueis a safe integer or a digit string ("1706659200000"); anything else returns null.- Limit at an offset with seconds. The instant is placed in the offset’s whole-minute zone, moved by its seconds, and the moved instant must be inside Temporal’s range. So within the offset’s seconds (under a minute) of the last instant Temporal supports (
+275760-09-13T00:00:00Z) for an offset east of UTC, or of the first (-271821-04-20T00:00:00Z) for one west, this returnsnull. An offset to the minute has no such limit.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | number | Unix epoch: a safe integer, or a string of optionally negative ASCII digits |
Options
Section titled “Options”options
optional: how value is read and the zone the quarter is found in
| Option | Type | Default | Description |
|---|---|---|---|
epochUnit? | "seconds" | "milliseconds" | "second" | "millisecond" (UnixUnit) | "milliseconds" | The unit the epoch values are counted in: "seconds" or "milliseconds", singular or plural. Any other value returns null. The result is in the same unit. |
timeZone? | string | "UTC" | The time zone the unit boundaries are found in: an IANA name, a UTC offset (a time zone identifier such as +05:30, +0530 or -08, or a stored offset ±HH:MM[:SS], what getTimeZoneOffset returns), or "local" for the system time zone. An unknown zone returns null. |
Returns
Section titled “Returns”Unix epoch number representing the end of the quarter, or null on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { endOfQuarterForUnix } from "@northguild/gmt/unix/calculate";
endOfQuarterForUnix(1706659200000, { timeZone: "UTC" }) // 1711929599999