Skip to content

isBetweenZoned

isBetweenZoned(zoned: string, start: string, end: string, options?: { inclusiveStart?: boolean; inclusiveEnd?: boolean; }): boolean
import { isBetweenZoned } from "@northguild/gmt/zoned/compare";

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.
Parameter Type Description
zoned string ISO ZonedDateTime string to check
start string ISO ZonedDateTime string for the start of the range
end string ISO ZonedDateTime string for the end of the range

options

Option Type Default
inclusiveStart? boolean
inclusiveEnd? boolean

boolean indicating whether zoned is between start and end

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
isBetweenZoned("invalid", "2024-02-29T11:00:00+00:00[UTC]", "2024-02-29T13:00:00+00:00[UTC]") // false

zoned/compare/isBetweenZoned.ts