Skip to content

intervalEngulfsUnix

intervalEngulfsUnix(aStart: string | number, aEnd: string | number, bStart: string | number, bEnd: string | number): boolean

Return true when the half-open interval B [bStart, bEnd) lies within the half-open interval A [aStart, aEnd) — every instant of B falls within A.

  • Compares numeric Unix epoch values directly.
  • B is inside A when the intervals overlap and aStart <= bStart and bEnd <= aEnd. Both ends are exclusive, so B may start at A’s start and end at A’s end.
  • An empty B counts only strictly inside A, the same edge rule as clampInterval; at either edge of A it returns false, and an empty A engulfs nothing.
  • Equivalent to 4-argument intervalContainsUnix(aStart, aEnd, bStart, bEnd).
  • Returns false if either interval is invalid (start > end).
  • Returns false on invalid input: non-numeric types, empty strings, and values that are not safe integers (fractions, NaN, ±Infinity, beyond ±(2^53 − 1)).
ParameterTypeDescription
aStartstring | numberUnix epoch value, in the one unit all epoch arguments share — outer interval start
aEndstring | numberUnix epoch value, in the one unit all epoch arguments share — outer interval end
bStartstring | numberUnix epoch value, in the one unit all epoch arguments share — inner interval start
bEndstring | numberUnix epoch value, in the one unit all epoch arguments share — inner interval end

true if B is fully contained in A, or false on invalid input

import { intervalEngulfsUnix } from "@northguild/gmt/unix/interval";
intervalEngulfsUnix(0, 1700000000, 1500000000, 1600000000) // true
output 

unix/interval/intervalEngulfsUnix.ts