formatCalendarUnix
Signature
Section titled “Signature”formatCalendarUnix(value: string | number, locale?: string, options?: FormatCalendarUnixOptions): stringimport { formatCalendarUnix } from "@northguild/gmt/unix/format";Format a unix epoch value as a relative day label plus time-of-day, e.g.
- “Tomorrow at 2:30 PM” — the unix counterpart of
formatCalendar. See that function’s JSDoc for the day-label/threshold/connector design; this variant compares calendar days and renders the clock time intimeZone(default"UTC").
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string | number |
unix epoch (string or number, per epochUnit) to format |
locale |
string |
optional: BCP 47 locale tag |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
epochUnit? |
"seconds" | "milliseconds" |
— |
reference? |
string | number |
— |
timeZone? |
string |
— |
timeStyle? |
"short" | "medium" | "full" |
— |
Returns
Section titled “Returns”the formatted calendar string, or “” on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”formatCalendarUnix(1710685845000, "en-US", { epochUnit: "milliseconds", timeZone: "America/New_York" }) // day label + time relative to "now", or the absolute fallback beyond the ±6-day thresholdformatCalendarUnix(value, "en-US", { reference: 1710685000000 }) // e.g. "tomorrow at 2:30 PM"formatCalendarUnix("not-a-number") // ""