@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
20 lines (19 loc) • 1.1 kB
TypeScript
/**
* Format a plain date range using the Temporal Intl.DateTimeFormat formatRange API.
*
* - Plain counterpart of `formatZonedRange` — same parameter order and option shape.
* - Uses Temporal.PlainDate.from for both endpoints; no timezone is involved.
* - Locale elides shared fields between `start` and `end` (e.g. same month/year).
* - Returns "" for invalid input on either endpoint.
*
* @param start ISO PlainDate string (range start)
* @param end ISO PlainDate string (range end)
* @param locale optional locale tag
* @param options optional Intl.DateTimeFormatOptions
* @returns localized range string or "" when invalid
*
* @example formatDateRange("2024-02-03", "2024-02-05", "en-US", { dateStyle: "long" }) // "February 3 – 5, 2024"
* @example formatDateRange("2024-02-03", "2024-06-10", "en-US", { dateStyle: "long" }) // "February 3 – June 10, 2024"
* @example formatDateRange("invalid", "2024-02-05", "en-US") // "" (invalid input)
*/
export declare function formatDateRange(start: string, end: string, locale?: string, options?: Intl.DateTimeFormatOptions): string;