Skip to content

startOfQuarterForZoned

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

Return 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 (see floorToZone), so the result is never after value: 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.
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)0The 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.

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

import { startOfQuarterForZoned } from "@northguild/gmt/zoned/calculate";
startOfQuarterForZoned("2024-02-15T14:30:00+00:00[UTC]") // "2024-01-01T00:00:00+00:00[UTC]"
output 

zoned/calculate/startOfQuarterForZoned.ts