relativeTime (time-format.ts)

agenticmail · email, date-formatting, duration-formatting, time-utils

Human-friendly date and duration formatting for the interactive shell. # Why this exists IMAP and the master API hand us dates as ISO 8601 strings or epoch milliseconds — `2026-05-13T16:22:46.000Z`. That's correct for the wire but unreadable in an inbox. A human scanning their

// Source: https://github.com/agenticmail/agenticmail | License: MIT | Copyright 2026 Ope Olatunji
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Human-friendly date and duration formatting for the interactive shell.
 *
 * # Why this exists
 *
 * IMAP and the master API hand us dates as ISO 8601 strings or epoch
 * milliseconds — `2026-05-13T16:22:46.000Z`. That's correct for the
 * wire but unreadable in an inbox. A human scanning their email wants
 * three things at once:
 *
 *   1. **A relative anchor** — "5 minutes ago", "yesterday", "last week"
 *   2. **An absolute time** — "Tue, May 13, 4:22 PM"
 *   3. **Local timezone** — never UTC, never the sender's TZ
 *
 * The shell used to call `new Date(msg.date).toLocaleString()` which
 * gives only #2 in a clunky f

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key