UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

30 lines • 1.33 kB
import { UnixUnit } from "../validate/isValidUnixUnit.js"; /** * Return whether `value1` represents an instant strictly before `value2`. * * - Uses Temporal.Instant.compare to check ordering. * - Each value is a safe integer or a string of optionally negative ASCII digits; anything else * is invalid. * - Returns false if either input is invalid. * * @param value1 first unix epoch: a safe integer or a digit string * @param value2 second unix epoch, in the same unit * @param options optional: how both epochs are read * @returns `true` if `value1` is before `value2`, otherwise `false` * * @example isBeforeUnix(1704067200, 1706659200) // true * @example isBeforeUnix(1706659200, 1706659200) // false * @example isBeforeUnix(-1, 0) // true (1969-12-31T23:59:59.999Z is before 1970-01-01T00:00:00Z) * @example isBeforeUnix('invalid', 1704067200000) // false * @example isBeforeUnix(1704067200000, 'invalid') // false * @example isBeforeUnix("-1", "0") // true (digit strings) */ export declare function isBeforeUnix(value1: number | string, value2: number | string, options?: { /** * The unit the epoch values are counted in: `"seconds"` or `"milliseconds"`, singular or * plural. Any other value returns `false`. * * @defaultValue `"milliseconds"` */ epochUnit?: UnixUnit; }): boolean;