Skip to content

isBetweenUtc

isBetweenUtc(value: string, start: string, end: string, options?: { inclusiveStart?: boolean; inclusiveEnd?: boolean; }): boolean
import { isBetweenUtc } from "@northguild/gmt/utc/calculate";

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.
  • Use options.inclusiveStart/inclusiveEnd to control boundaries.
Parameter Type Description
value string ISO UTC datetime string to check
start string ISO UTC datetime string for range start
end string ISO UTC datetime string for range end

options

Option Type Default
inclusiveStart? boolean
inclusiveEnd? boolean

boolean indicating whether value is between start and end

isBetweenUtc("2024-03-15T12:00:00Z", "2024-03-10T12:00:00Z", "2024-03-20T12:00:00Z") // true
isBetweenUtc("2024-03-25T12:00:00Z", "2024-03-10T12:00:00Z", "2024-03-20T12:00:00Z") // false
isBetweenUtc("invalid", "2024-03-10T12:00:00Z", "2024-03-20T12:00:00Z") // false

utc/calculate/isBetweenUtc.ts