Skip to content

isBetweenUtc

isBetweenUtc(value: string, start: string, end: string, options?: { inclusiveStart?: boolean; inclusiveEnd?: boolean; }): boolean

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.
ParameterTypeDescription
valuestringISO UTC datetime string to check
startstringISO UTC datetime string for range start
endstringISO UTC datetime string for range end

options

Whether each boundary counts as inside the range

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

boolean indicating whether value is between start and end

import { isBetweenUtc } from "@northguild/gmt/utc/calculate";
isBetweenUtc("2024-03-15T12:00:00Z", "2024-03-10T12:00:00Z", "2024-03-20T12:00:00Z") // true
output 

utc/calculate/isBetweenUtc.ts