Skip to content

isBetweenTime

isBetweenTime(time: string, start: string, end: string, options?: { inclusiveStart?: boolean; inclusiveEnd?: boolean; }): boolean

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.
ParameterTypeDescription
timestringISO PlainTime string to check
startstringISO PlainTime string for the start of the range
endstringISO PlainTime string for the end of the range

options

Whether each end of the range counts as inside it

OptionTypeDefaultDescription
inclusiveStart?booleantrueWhether time equal to start counts as inside the range. false requires it to be after start.
inclusiveEnd?booleantrueWhether time equal to end counts as inside the range. false requires it to be before end.

boolean indicating whether time is between start and end

import { isBetweenTime } from "@northguild/gmt/plain/compare";
isBetweenTime("12:34:56", "12:00:00", "13:00:00") // true
output 

plain/compare/isBetweenTime.ts