UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

14 lines • 617 B
/** * Sort an array of PlainDate values in ascending or descending order. * * - Returns empty array if no valid dates. * - Validation is performed on each item in the array. * * @param dates Array of ISO PlainDate strings (e.g. "2024-03-10") * @param order "asc" for ascending (earliest first) | "desc" for descending (latest first) * @returns Sorted array of date strings * * @example sortDates(["2024-03-10", "2024-01-01", "2024-02-15"]) // ["2024-01-01", "2024-02-15", "2024-03-10"] * @example sortDates([]) // [] */ export declare function sortDates(dates: string[], order?: "asc" | "desc"): string[];