Skip to content

mapZonedDatesInRange

mapZonedDatesInRange(startZonedDateTime: string, endZonedDateTime: string, stepDays?: number): string[]
import { mapZonedDatesInRange } from "@northguild/gmt/zoned/map";

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.
Parameter Type Description
startZonedDateTime string start zoned ISO 8601 datetime string
endZonedDateTime string end zoned ISO 8601 datetime string
stepDays `` optional positive integer step in days

array of ISO date strings or [] when invalid

mapZonedDatesInRange("2024-02-28T12:00:00+00:00[UTC]", "2024-03-02T12:00:00+00:00[UTC]") // ["2024-02-28", "2024-02-29", "2024-03-01", "2024-03-02"]
mapZonedDatesInRange("2024-02-28T12:00:00+00:00[UTC]", "2024-03-02T12:00:00+00:00[UTC]", 2) // ["2024-02-28", "2024-03-01"]
mapZonedDatesInRange("invalid", "2024-03-02T12:00:00+00:00[UTC]") // []

zoned/map/mapZonedDatesInRange.ts