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.

23 lines • 1.44 kB
/** * Return true if `start` and `end` form a valid UTC interval — both parseable as * ISO UTC datetime strings and the instant at `start` is <= the instant at `end`. * * - Both inputs must be ISO 8601 UTC datetime strings (e.g. `"2024-01-01T10:00:00Z"`). * - Equal `start === end` is valid. * - Leap-second strings return `false`. * - Invalid input or malformed strings return `false`. * - Each endpoint must satisfy `isValidUtc`, so an annotation of any kind (a time zone, a * calendar, an elective one) returns `false`. * * @param start ISO 8601 UTC datetime string (interval start) * @param end ISO 8601 UTC datetime string (interval end) * @returns true if start and end form a valid UTC interval, or false on invalid input * * @example isValidUtcInterval("2024-01-01T10:00:00Z", "2024-12-31T23:59:59Z") // true * @example isValidUtcInterval("2024-01-01T10:00:00Z", "2024-01-01T10:00:00Z") // true * @example isValidUtcInterval("2024-12-31T23:59:59Z", "2024-01-01T10:00:00Z") // false * @example isValidUtcInterval("invalid", "2024-12-31T23:59:59Z") // false * @example isValidUtcInterval("2024-01-01T10:00:00Z[u-ca=hebrew]", "2024-12-31T23:59:59Z[foo=bar]") // false (no annotation of any kind) * @example isValidUtcInterval("2024-01-01T10:00:00Z[!foo=bar]", "2024-12-31T23:59:59Z") // false (unknown critical annotation) */ export declare function isValidUtcInterval(start: string, end: string): boolean;