endOfQuarterForZoned
Signature
Section titled “Signature”endOfQuarterForZoned(value: string, optionsArg?: { fractionalSecondDigits?: FractionalDigit; }): stringReturn 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.
- Returns one nanosecond before the next local quarter starts in
value’s own zone (seefloorToZone), so the result is never beforevalue: a quarter whose last local hour repeats (Africa/Cairo, 2010-09-30) ends with the second pass. - The end is written at nanosecond precision by default, so the string names the end itself.
- Validation is performed on the input.
- Compatibility: before 1.16.0 the default printed no fractional digits, which wrote a moment earlier than the end. Pass
{ fractionalSecondDigits: 0 }to keep the previous string.
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) | 9 | The number of fractional-second digits the result is written with, 0 to 9, or "auto" to drop trailing zeros. Fewer than 9 digits truncate the string, as Temporal’s toString does, so it names a moment before the end. |
Returns
Section titled “Returns”ISO ZonedDateTime string for the end of the quarter, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { endOfQuarterForZoned } from "@northguild/gmt/zoned/calculate";
endOfQuarterForZoned("2024-02-15T14:30:00+00:00[UTC]") // "2024-03-31T23:59:59.999999999+00:00[UTC]"