feat: Nicer date

This commit is contained in:
Brennan Wilkes (Text Groove) 2026-01-21 20:31:58 -08:00
parent 7b7bf44dd3
commit decb0ad8ef

View file

@ -18,8 +18,12 @@ export function esc(s) {
const s = String(iso || ""); const s = String(iso || "");
if (!s) return ""; if (!s) return "";
const d = new Date(s); const d0 = new Date(s);
if (!Number.isFinite(d.getTime())) return ""; const t0 = d0.getTime();
if (!Number.isFinite(t0)) return "";
// Round to nearest hour
const d = new Date(Math.round(t0 / 3600000) * 3600000);
const parts = new Intl.DateTimeFormat("en-US", { const parts = new Intl.DateTimeFormat("en-US", {
timeZone: "America/Vancouver", timeZone: "America/Vancouver",
@ -44,11 +48,9 @@ export function esc(s) {
else if (p.type === "dayPeriod") dayPeriod = p.value; else if (p.type === "dayPeriod") dayPeriod = p.value;
} }
const ampm = String(dayPeriod || "").toLowerCase(); // "am"/"pm" return `${month} ${day} ${hour}:${minute}${String(dayPeriod || "").toLowerCase()}`;
return `${month} ${day} ${hour}:${minute}${ampm}`;
} }
export function renderThumbHtml(imgUrl, cls = "thumb") { export function renderThumbHtml(imgUrl, cls = "thumb") {
const img = normImg(imgUrl); const img = normImg(imgUrl);
if (!img) return `<div class="thumbPlaceholder"></div>`; if (!img) return `<div class="thumbPlaceholder"></div>`;