Skip to content

isValidUnixInterval

isValidUnixInterval(start: string | number, end: string | number): boolean

Return true if start and end form a valid Unix interval — both safe-integer epochs and start <= end.

  • Each input must be a safe integer (Number.isSafeInteger) or a string of optionally negative ASCII digits naming one — the epoch grammar every unix/ function shares.
  • Fractional values, NaN, ±Infinity and anything beyond ±(2^53 − 1) return false.
  • Strings with whitespace, +, a decimal point, an exponent or hex digits return false, and an empty string is not epoch 0.
  • Equal start === end is valid.
ParameterTypeDescription
startstring | numberUnix epoch value, in the one unit all epoch arguments share — interval start
endstring | numberUnix epoch value, in the one unit all epoch arguments share — interval end

true if start and end form a valid Unix interval, or false on invalid input

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

unix/interval/validate/isValidUnixInterval.ts