areUnixEqualBy
Signature
Section titled “Signature”areUnixEqualBy(value1: number, value2: number, unit: DateTimeUnit, options?: { epochUnit?: UnixUnit; timeZone?: string; weekStartsOn?: "monday" | "sunday"; }): booleanimport { areUnixEqualBy } from "@northguild/gmt/unix/compare";Compare two Unix epoch values for equality at a given unit.
- Both values are resolved to the start of
unitinoptions.timeZone(default: the system time zone) before comparison, so"day"compares calendar days in that zone, not raw epoch buckets. "month"requires the same month AND year, matchingareDateTimesEqualBy.- Returns false for an unsupported unit or invalid input. Mapping from date-fns (Decision 5,
context/roadmap/issues/J.md): isSameDay(a, b)→areUnixEqualBy(a, b, "day")isSameMonth(a, b)→areUnixEqualBy(a, b, "month")isSameYear(a, b)→areUnixEqualBy(a, b, "year")
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value1 |
number |
first Unix epoch value |
value2 |
number |
second Unix epoch value |
unit |
DateTimeUnit |
Temporal.DateUnit | Temporal.TimeUnit to compare by |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
epochUnit? |
UnixUnit |
— |
timeZone? |
string |
— |
weekStartsOn? |
"monday" | "sunday" |
— |
Returns
Section titled “Returns”true if both values share the same start-of-unit boundary, false on an unsupported unit or invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”areUnixEqualBy(1710498000000, 1710503000000, "day", { timeZone: "UTC" }) // true (both fall on 2024-03-15 in UTC)areUnixEqualBy(1704067200000, 1735689600000, "year", { timeZone: "UTC" }) // false (2024-01-01 vs 2025-01-01)areUnixEqualBy(Number.NaN, 1710498000000, "day") // false