UNPKG

@burglekitt/gmt

Version:

Temporal-based date and time utilities with timezone support and polyfill integration

20 lines (19 loc) 1.09 kB
/** * 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. * * @param startDate ISO PlainDate string for the first date * @param endDate ISO PlainDate string for the last date (inclusive) * @param stepDays optional number of days to step between results * @returns array of ISO PlainDate strings, or [] on invalid input * * @example mapDatesInRange("2024-03-01", "2024-03-05") // ["2024-03-01", "2024-03-02", "2024-03-03", "2024-03-04", "2024-03-05"] * @example mapDatesInRange("2024-03-01", "2024-03-05", 2) // ["2024-03-01", "2024-03-03", "2024-03-05"] * @example mapDatesInRange("2024-03-05", "2024-03-01") // [] * @example mapDatesInRange("invalid", "2024-03-05") // [] * @example mapDatesInRange("2024-03-01", "invalid") // [] * @example mapDatesInRange("2024-03-01", "2024-03-05", 0) // [] */ export declare function mapDatesInRange(startDate: string, endDate: string, ...stepDaysInput: [stepDays?: number]): string[];