mapDatesInRange
Signature
Section titled “Signature”mapDatesInRange(startDate: string, endDate: string, stepDays?: number): string[]import { mapDatesInRange } from "@northguild/gmt/plain/map";Return an array of ISO PlainDate strings between startDate and endDate inclusive.
- Generates dates with optional step (default 1 day).
- Returns [] if start > end, invalid inputs, or step <= 0.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
startDate |
string |
ISO PlainDate string for the first date |
endDate |
string |
ISO PlainDate string for the last date (inclusive) |
stepDays |
`` | optional number of days to step between results |
Returns
Section titled “Returns”array of ISO PlainDate strings, or [] on invalid input
Examples
Section titled “Examples”mapDatesInRange("2024-03-01", "2024-03-05") // ["2024-03-01", "2024-03-02", "2024-03-03", "2024-03-04", "2024-03-05"]mapDatesInRange("2024-03-01", "2024-03-05", 2) // ["2024-03-01", "2024-03-03", "2024-03-05"]mapDatesInRange("2024-03-05", "2024-03-01") // []mapDatesInRange("invalid", "2024-03-05") // []mapDatesInRange("2024-03-01", "invalid") // []mapDatesInRange("2024-03-01", "2024-03-05", 0) // []