isPastCutoff
Signature
Section titled “Signature”isPastCutoff(now: string, cutoff: string): booleanReport 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, sonowequal tocutoffis past. This matches the half-open rule GMT’s intervals follow, andtimeToCutoff, which isPT0Sthere. - Both arguments are exact: an instant (
Z/offset) or a zoned string, ascutoffAtreturns 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, asTemporal.ZonedDateTime.fromreads it, so a cut-offcutoffAtwrote is the instant it computed, except a wall time repeated inside a sub-minute offset change, which reads as its first pass (seeisValidInstant). Otherwise the bracket is not checked: a zone that does not exist, or that disagrees with the offset, changes nothing. nowis the caller’s: GMT does not read the clock here, so the answer is reproducible.- Returns
falseon invalid input, includingcutoffAt’s""sentinel — which reads as “not past”. Check the cut-off is not""before trusting afalse.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
now | string | ISO 8601 instant or zoned datetime string of the moment asked about |
cutoff | string | ISO 8601 instant or zoned datetime string of the cut-off |
Returns
Section titled “Returns”true when now is at or after the cut-off, false otherwise or on invalid input
Examples
Section titled “Examples”import { isPastCutoff } from "@northguild/gmt/transport/compare";
isPastCutoff("2024-06-12T16:00:00Z", "2024-06-12T17:00:00+02:00[Europe/Amsterdam]") // true