Skip to content

endOfQuarterForZoned

endOfQuarterForZoned(value: string, optionsArg?: { fractionalSecondDigits?: FractionalDigit; }): string

Return 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 (see floorToZone), so the result is never before value: 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.
ParameterTypeDescription
valuestringISO ZonedDateTime string

optionsArg

optional setting for the precision of the output string

OptionTypeDefaultDescription
fractionalSecondDigits?0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | "auto" | 8 | 9 (FractionalDigit)9The 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.

ISO ZonedDateTime string for the end of the quarter, or "" on invalid input

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]"
output 

zoned/calculate/endOfQuarterForZoned.ts