UNPKG

@burglekitt/gmt

Version:

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

20 lines (19 loc) 1.27 kB
/** * Format a plain datetime range using the Temporal Intl.DateTimeFormat formatRange API. * * - Plain counterpart of `formatZonedRange` — same parameter order and option shape. * - Uses Temporal.PlainDateTime.from for both endpoints; no timezone is involved. * - Locale elides shared fields between `start` and `end` (e.g. same day/month/year). * - Returns "" for invalid input on either endpoint. * * @param start ISO PlainDateTime string (range start) * @param end ISO PlainDateTime string (range end) * @param locale optional locale tag * @param options optional Intl.DateTimeFormatOptions * @returns localized range string or "" when invalid * * @example formatDateTimeRange("2024-02-03T09:00:00", "2024-02-03T17:00:00", "en-US", { dateStyle: "long", timeStyle: "short" }) // "February 3, 2024, 9:00 AM – 5:00 PM" * @example formatDateTimeRange("2024-02-03T09:00:00", "2024-02-10T17:00:00", "en-US", { dateStyle: "long", timeStyle: "short" }) // "February 3, 2024 at 9:00 AM – February 10, 2024 at 5:00 PM" * @example formatDateTimeRange("invalid", "2024-02-03T17:00:00", "en-US") // "" (invalid input) */ export declare function formatDateTimeRange(start: string, end: string, locale?: string, options?: Intl.DateTimeFormatOptions): string;