@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.
31 lines • 1.52 kB
TypeScript
import { UnixUnit } from "../validate/isValidUnixUnit.js";
/**
* Return whether `value1` and `value2` represent the same instant.
*
* - Uses Temporal.Instant.compare to check equality.
* - 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` and `value2` are equal, otherwise `false`
*
* @example areUnixEqual(1706659200, 1706659200) // true
* @example areUnixEqual(1706659200, 1704067200) // false
* @example areUnixEqual(1706659200, 1706659200000, { epochUnit: "seconds" }) // false (epochUnit applies to both values)
* @example areUnixEqual(1706659200, 1706659200000) // false
* @example areUnixEqual(-86400000, 0) // false (1969-12-31 is not equal to 1970-01-01)
* @example areUnixEqual("1706659200", 1706659200, { epochUnit: "second" }) // true (a digit string is the same epoch)
* @example areUnixEqual("1706659200.0", 1706659200) // false (not a digit string)
*/
export declare function areUnixEqual(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;