Skip to content

mapZonedDatesInRange

mapZonedDatesInRange(startZonedDateTime: string, endZonedDateTime: string, stepDays?: number, options?: { maxPieces?: number; }): string[]

Return an array of plain ISO date strings covering the inclusive date range between two zoned datetimes.

  • Both datetimes must have the same timezone.
  • Returns [] for invalid inputs, mismatched timezones, start > end, or invalid step.
  • A range holding more dates than options.maxPieces returns [] without generating any.
  • An explicit undefined stepDays is the default step, so (start, end, undefined, options) reaches options. Compatibility: before 1.16.0 it returned [].
  • End-inclusive, where the interval* functions are half-open. This enumerates the dates a range covers, so the end date is one of them; an interval bounds a span as [start, end), so its end is not. The same pair therefore yields one more date here than intervalCountZoned counts.
ParameterTypeDescription
startZonedDateTimestringstart zoned ISO 8601 datetime string
endZonedDateTimestringend zoned ISO 8601 datetime string
stepDaysnumberoptional positive integer step in days

options

optional limit on the size of the output

OptionTypeDefaultDescription
maxPieces?number1_000_000The most dates the result may hold. A result that would hold more, or more than the longest possible array (2^32 - 1 elements), returns [] and none is built. A value that is not a positive safe integer also returns [].

array of ISO date strings or [] when invalid

import { mapZonedDatesInRange } from "@northguild/gmt/zoned/map";
mapZonedDatesInRange("+275760-09-12T00:00:00+00:00[UTC]", "+275760-09-13T00:00:00+00:00[UTC]") // ["+275760-09-12", "+275760-09-13"] (a range ending on the maximum instant)
output 

zoned/map/mapZonedDatesInRange.ts