@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.
32 lines • 1.27 kB
TypeScript
/**
* Return true when `value` is between `start` and `end` (inclusive by default).
*
* - Uses Temporal.Instant.compare for comparison.
* - Returns false if start > end or inputs are invalid.
*
* @param value ISO UTC datetime string to check
* @param start ISO UTC datetime string for range start
* @param end ISO UTC datetime string for range end
* @param options Whether each boundary counts as inside the range
* @returns boolean indicating whether value is between start and end
*
* @example isBetweenUtc("2024-03-15T12:00:00Z", "2024-03-10T12:00:00Z", "2024-03-20T12:00:00Z") // true
* @example isBetweenUtc("2024-03-25T12:00:00Z", "2024-03-10T12:00:00Z", "2024-03-20T12:00:00Z") // false
* @example isBetweenUtc("invalid", "2024-03-10T12:00:00Z", "2024-03-20T12:00:00Z") // false
*/
export declare function isBetweenUtc(value: string, start: string, end: string, options?: {
/**
* Whether `value` equal to `start` counts as inside the range. `false` requires it to be after
* `start`.
*
* @defaultValue `true`
*/
inclusiveStart?: boolean;
/**
* Whether `value` equal to `end` counts as inside the range. `false` requires it to be before
* `end`.
*
* @defaultValue `true`
*/
inclusiveEnd?: boolean;
}): boolean;