Fix archive bar chart: fmtDate now handles ISO datetime strings from PostgreSQL date columns

This commit is contained in:
Jordan Ramos
2026-05-12 14:57:15 -06:00
parent 8c93e86fe0
commit f3d7f2ac1d

View File

@@ -170,13 +170,15 @@ function ArchiveTooltip({ active, payload, label }) {
}
// ---------------------------------------------------------------------------
// Shorten YYYY-MM-DD to MM/DD/YY
// Shorten YYYY-MM-DD (or ISO datetime) to MM/DD/YY
// ---------------------------------------------------------------------------
function fmtDate(d) {
if (!d) return '';
const p = d.split('-');
// Handle ISO datetime strings (e.g. "2026-05-12T06:00:00.000Z") — extract date part first
const dateStr = String(d).split('T')[0];
const p = dateStr.split('-');
if (p.length === 3) return `${p[1]}/${p[2]}/${p[0].slice(2)}`;
return d;
return dateStr;
}
// Extract YYYY-MM-DD from a datetime string