startOfQuarterForZoned
Signature
Section titled “Signature”startOfQuarterForZoned(value: string, optionsArg?: { fractionalSecondDigits?: FractionalDigit; }): stringReturn the start of the quarter for a given zoned ISO datetime.
- Calculates which quarter (1-4) the date falls into and returns the first instant of that quarter, with every field below the day reset — milliseconds, microseconds and nanoseconds included.
- Returns the real start of the local quarter in
value’s own zone (seefloorToZone), so the result is never aftervalue: a skipped first midnight starts at the quarter’s first real instant, and a repeated one (Africa/Tunis, 1978-10-01) at its first pass. - Validation is performed on the input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO ZonedDateTime string |
Options
Section titled “Options”optionsArg
optional setting for the precision of the output string
| Option | Type | Default | Description |
|---|---|---|---|
fractionalSecondDigits? | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | "auto" | 8 | 9 (FractionalDigit) | 0 | The number of fractional-second digits the result is written with, 0 to 9, or "auto" to drop trailing zeros. A start has no sub-second part, so any digits written are zeros. |
Returns
Section titled “Returns”ISO ZonedDateTime string for the start of the quarter, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { startOfQuarterForZoned } from "@northguild/gmt/zoned/calculate";
startOfQuarterForZoned("2024-02-15T14:30:00+00:00[UTC]") // "2024-01-01T00:00:00+00:00[UTC]"