Skip to content

isBetweenZoned

isBetweenZoned(zoned: string, start: string, end: string, options?: { inclusiveStart?: boolean; inclusiveEnd?: boolean; }): boolean

Return true when zoned is between start and end (inclusive by default).

  • Validates inputs and then compares using Temporal.Instant (same instant semantics).
  • Returns false for invalid inputs.
ParameterTypeDescription
zonedstringISO ZonedDateTime string to check
startstringISO ZonedDateTime string for the start of the range
endstringISO ZonedDateTime string for the end of the range

options

optional settings for whether each end of the range is included

OptionTypeDefaultDescription
inclusiveStart?booleantrueWhether zoned at the same instant as start counts as inside the range. false requires it to be after start.
inclusiveEnd?booleantrueWhether zoned at the same instant as end counts as inside the range. false requires it to be before end.

boolean indicating whether zoned is between start and end

import { isBetweenZoned } from "@northguild/gmt/zoned/compare";
isBetweenZoned("2024-02-29T12:00:00+00:00[UTC]", "2024-02-29T11:00:00+00:00[UTC]", "2024-02-29T13:00:00+00:00[UTC]") // true
output 

zoned/compare/isBetweenZoned.ts