13 lines · 471 BRaw
| 1 | import { formatAgo } from "../format"; |
| 2 | |
| 3 | const EXACT = new Intl.DateTimeFormat("en-US", { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }); |
| 4 | |
| 5 | /** A relative time, such as "17 minutes ago", that shows the exact time on hover. */ |
| 6 | export function Ago({ at, now }: { at: number; now: number }) { |
| 7 | const date = new Date(at * 1000); |
| 8 | return ( |
| 9 | <time dateTime={date.toISOString()} title={`${EXACT.format(date)} UTC`}> |
| 10 | {formatAgo(at, now)} |
| 11 | </time> |
| 12 | ); |
| 13 | } |