const time = new Intl.DateTimeFormat(undefined, { hour: "numeric", minute: "numeric" }); const month = new Intl.DateTimeFormat("en", { month: "short", day: "numeric" }); const year = new Intl.DateTimeFormat(undefined, { month: "short", year: "numeric", day: "numeric" }); export function formatDate(date: Date | string | number) { date = date instanceof Date ? date : new Date(date); const now = new Date(); if (date.toDateString() === now.toDateString()) { return time.format(date); } else if (date.getFullYear() === now.getFullYear()) { return month.format(date); } else { return year.format(date); } }