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.

39 lines • 1.65 kB
/** * Return true when `time` is between `start` and `end` (inclusive by default). * * - Uses Temporal.PlainTime.compare to compare times. * - Returns false if start > end (invalid range). * - Returns false if any input is invalid. * - Note: PlainTime comparison does not account for day overflow. * * @param time ISO PlainTime string to check * @param start ISO PlainTime string for the start of the range * @param end ISO PlainTime string for the end of the range * @param options Whether each end of the range counts as inside it * @returns boolean indicating whether time is between start and end * * @example isBetweenTime("12:34:56", "12:00:00", "13:00:00") // true * @example isBetweenTime("12:34:56", "12:34:56", "13:00:00") // true * @example isBetweenTime("12:34:56", "12:34:57", "13:00:00") // false * @example isBetweenTime("12:34:56", "12:00:00", "12:34:56") // true * @example isBetweenTime("12:34:56", "12:00:00", "12:34:55") // false * @example isBetweenTime("invalid", "12:00:00", "13:00:00") // false * @example isBetweenTime("12:34:56", "invalid", "13:00:00") // false * @example isBetweenTime("12:34:56", "12:00:00", "invalid") // false */ export declare function isBetweenTime(time: string, start: string, end: string, options?: { /** * Whether `time` equal to `start` counts as inside the range. `false` requires it to * be after `start`. * * @defaultValue `true` */ inclusiveStart?: boolean; /** * Whether `time` equal to `end` counts as inside the range. `false` requires it to be * before `end`. * * @defaultValue `true` */ inclusiveEnd?: boolean; }): boolean;