Compact "edited 3h ago" style stamp; falls back to a short date past a week.
(ts: number, now: number)
| 29 | |
| 30 | /** Compact "edited 3h ago" style stamp; falls back to a short date past a week. */ |
| 31 | function timeAgo(ts: number, now: number): string { |
| 32 | const mins = Math.round((now - ts) / 60000) |
| 33 | if (mins < 1) return 'just now' |
| 34 | if (mins < 60) return `${mins}m ago` |
| 35 | const hrs = Math.round(mins / 60) |
| 36 | if (hrs < 24) return `${hrs}h ago` |
| 37 | const days = Math.round(hrs / 24) |
| 38 | if (days === 1) return 'yesterday' |
| 39 | if (days < 7) return `${days}d ago` |
| 40 | return new Date(ts).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) |
| 41 | } |
| 42 | |
| 43 | /** A light landing view shown when no note is open: the few most recently |
| 44 | * edited notes plus the open tasks for today. Keyboard: ↑/↓ (and j/k in vim |