temporal-fns
API reference

isWithinInterval

API index · Input types and conventions · Installation

isWithinInterval(value, interval) → boolean

Check membership in a closed interval, including both endpoints. Equal endpoints form a valid point interval.

import { isWithinInterval } from '@frantss/temporal-fns';

const interval = {
  start: Temporal.PlainTime.from('10:00'),
  end: Temporal.PlainTime.from('12:00'),
};
isWithinInterval(Temporal.PlainTime.from('10:00'), interval); // => true
isWithinInterval(Temporal.PlainTime.from('12:00'), interval); // => true
isWithinInterval(Temporal.PlainTime.from('12:00:00.000000001'), interval); // => false
const month = Temporal.PlainYearMonth.from('2026-10');
isWithinInterval(month, { start: month, end: month }); // => true

Related: clamp, areIntervalsOverlapping, eachDayOfInterval.

Behaviors: INT-001: Membership includes both endpoints; INT-006: Point membership and clamping still use closed endpoints; INT-008: Month-only intervals use inclusive month endpoints; INT-009: Zoned interval membership compares exact instants across different zones; INT-007: Reversed intervals are invalid for every interval query.