Skip to content

isPastCutoff

  • Legs, dwell, cut-offs and punctuality, shared by road, rail, sea and air.
isPastCutoff(now: string, cutoff: string): boolean

Report whether a cut-off has passed.

  • The window to meet a cut-off is half-open, […, cutoff): at the cut-off instant itself it has closed, so now equal to cutoff is past. This matches the half-open rule GMT’s intervals follow, and timeToCutoff, which is PT0S there.
  • Both arguments are exact: an instant (Z/offset) or a zoned string, as cutoffAt returns one. They are compared as instants, so the zone each is written in does not matter, and the two passes of a repeated hour are told apart by their offsets.
  • The offset fixes the instant; a bracketed zone only resolves a rounded one. An offset written to the minute that is the bracketed zone’s sub-minute offset rounded (-00:45[Africa/Monrovia], for −00:44:30) names the instant the zone gives, as Temporal.ZonedDateTime.from reads it, so a cut-off cutoffAt wrote is the instant it computed, except a wall time repeated inside a sub-minute offset change, which reads as its first pass (see isValidInstant). Otherwise the bracket is not checked: a zone that does not exist, or that disagrees with the offset, changes nothing.
  • now is the caller’s: GMT does not read the clock here, so the answer is reproducible.
  • Returns false on invalid input, including cutoffAt’s "" sentinel — which reads as “not past”. Check the cut-off is not "" before trusting a false.
ParameterTypeDescription
nowstringISO 8601 instant or zoned datetime string of the moment asked about
cutoffstringISO 8601 instant or zoned datetime string of the cut-off

true when now is at or after the cut-off, false otherwise or on invalid input

import { isPastCutoff } from "@northguild/gmt/transport/compare";
isPastCutoff("2024-06-12T16:00:00Z", "2024-06-12T17:00:00+02:00[Europe/Amsterdam]") // true
output 

transport/compare/isPastCutoff.ts