Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 5x 72x 12x 12x 10x 1x 1x | import { dayOffset } from './timeline'
// 24-hour clock, "09:05": one format for every time on the screen (the prototype's).
const CLOCK = new Intl.DateTimeFormat('en-GB', {
hour: '2-digit',
minute: '2-digit',
hourCycle: 'h23',
})
export function formatClock(time: number): string {
return CLOCK.format(time)
}
// "today at 18:09", "yesterday at 18:09", or the date for anything older.
export function formatLastReply(time: number, now: number): string {
const offset = dayOffset(new Date(time).setHours(0, 0, 0, 0), now)
if (offset === 0) return `today at ${formatClock(time)}`
if (offset === 1) return `yesterday at ${formatClock(time)}`
const date = new Intl.DateTimeFormat('en-GB', { day: 'numeric', month: 'short' }).format(time)
return `${date} at ${formatClock(time)}`
}
|