Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Times read as people say them, and old ones as their date: every TimeAgo across the site (283 of them) said "1176d ago" for a commit three years old, since it only knew days, hours and minutes. It now says "just now", "5m ago", "3h ago", "yesterday", "4d ago" and "3w ago", then the date, "Sep 30" this year and "Jul 24, 2023" before, from lib/time-ago.ts, and the moment in full ("Oct 13, 2026, 3:04 PM UTC") shows in the site's tooltip on hover. A deployment's status no longer wraps its time in a second hint of its own. A time that can't be read shows nothing rather than "NaN". Checked: the site's typecheck, its 893 tests (new: time-ago's wording for each span, a clock slightly ahead, an unreadable time and the full moment) and a production build. | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { exactTime, timeAgo } from "./time-ago.ts"; | |
| 5 | ||
| 6 | const NOW = Date.parse("2026-10-13T12:00:00.000Z"); | |
| 7 | const before = (ms: number) => new Date(NOW - ms).toISOString(); | |
| 8 | const MINUTE = 60_000; | |
| 9 | const HOUR = 60 * MINUTE; | |
| 10 | const DAY = 24 * HOUR; | |
| 11 | ||
| 12 | test("a moment within the last week is said in minutes, hours or days", () => { | |
| 13 | assert.equal(timeAgo(before(10_000), NOW, "UTC"), "just now"); | |
| 14 | assert.equal(timeAgo(before(-30_000), NOW, "UTC"), "just now"); | |
| 15 | assert.equal(timeAgo(before(50_000), NOW, "UTC"), "1m ago"); | |
| 16 | assert.equal(timeAgo(before(5 * MINUTE), NOW, "UTC"), "5m ago"); | |
| 17 | assert.equal(timeAgo(before(3 * HOUR), NOW, "UTC"), "3h ago"); | |
| 18 | assert.equal(timeAgo(before(30 * HOUR), NOW, "UTC"), "yesterday"); | |
| 19 | assert.equal(timeAgo(before(4 * DAY), NOW, "UTC"), "4d ago"); | |
| 20 | }); | |
| 21 | ||
| 22 | test("a moment weeks ago is said in weeks, and older ones by their date", () => { | |
| 23 | assert.equal(timeAgo(before(10 * DAY), NOW, "UTC"), "1w ago"); | |
| 24 | assert.equal(timeAgo(before(27 * DAY), NOW, "UTC"), "3w ago"); | |
| 25 | assert.equal(timeAgo("2026-09-01T09:00:00.000Z", NOW, "UTC"), "Sep 1"); | |
| 26 | assert.equal(timeAgo("2023-07-24T09:00:00.000Z", NOW, "UTC"), "Jul 24, 2023"); | |
| 27 | assert.equal(timeAgo(Date.parse("2023-07-24T09:00:00.000Z"), NOW, "UTC"), "Jul 24, 2023"); | |
| 28 | }); | |
| 29 | ||
| 30 | test("a moment that can't be read says nothing", () => { | |
| 31 | assert.equal(timeAgo("not a date", NOW), ""); | |
| 32 | assert.equal(exactTime("not a date"), ""); | |
| 33 | }); | |
| 34 | ||
| 35 | test("the hint gives the moment in full", () => { | |
| 36 | assert.equal(exactTime("2026-10-13T15:04:00.000Z", "UTC"), "Oct 13, 2026, 3:04 PM UTC"); | |
| 37 | }); |