mapZonedDatesInRange
Signature
Section titled “Signature”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.maxPiecesreturns[]without generating any. - An explicit
undefinedstepDaysis the default step, so(start, end, undefined, options)reachesoptions. 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 itsendis not. The same pair therefore yields one more date here thanintervalCountZonedcounts.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
startZonedDateTime | string | start zoned ISO 8601 datetime string |
endZonedDateTime | string | end zoned ISO 8601 datetime string |
stepDays | number | optional positive integer step in days |
Options
Section titled “Options”options
optional limit on the size of the output
| Option | Type | Default | Description |
|---|---|---|---|
maxPieces? | number | 1_000_000 | The 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 []. |
Returns
Section titled “Returns”array of ISO date strings or [] when invalid
Examples
Section titled “Examples”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)