Skip to content

isBeforeUnix

isBeforeUnix(value1: number, value2: number, options?: { epochUnit?: UnixUnit; }): boolean
import { isBeforeUnix } from "@northguild/gmt/unix/compare";

Return whether value1 represents an instant strictly before value2.

  • Uses Temporal.Instant.compare to check ordering.
  • Returns false if either input is invalid.
Parameter Type Description
value1 number first unix epoch value
value2 number second unix epoch value

options

Option Type Default
epochUnit? UnixUnit

true if value1 is before value2, otherwise false

isBeforeUnix(1704067200, 1706659200) // true
isBeforeUnix(1706659200, 1706659200) // false
isBeforeUnix(-1, 0) // true (1969-12-31T23:59:59.999Z is before 1970-01-01T00:00:00Z)
isBeforeUnix('invalid', 1704067200000) // false
isBeforeUnix(1704067200000, 'invalid') // false

unix/compare/isBeforeUnix.ts