From 013a2fc2d6f569d1d7378c7388bb53b80b54cc9a Mon Sep 17 00:00:00 2001 From: Mistral Vibe Date: Mon, 6 Apr 2026 18:40:38 +0200 Subject: [PATCH] Fix Invalid Date for datetime strings from API The API returns dates as "2024-12-11T00:00:00" (datetime, no timezone), not bare "2024-12-11". Appending T12:00:00 directly produced an invalid string. Use .slice(0, 10) to extract the date part first before parsing. Co-Authored-By: Claude Sonnet 4.6 --- web/src/pages/BandPage.tsx | 4 ++-- web/src/pages/SessionPage.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/pages/BandPage.tsx b/web/src/pages/BandPage.tsx index 6dfb29c..c135cb3 100644 --- a/web/src/pages/BandPage.tsx +++ b/web/src/pages/BandPage.tsx @@ -26,12 +26,12 @@ type FilterPill = "all" | "full band" | "guitar" | "vocals" | "drums" | "keys" | const PILLS: FilterPill[] = ["all", "full band", "guitar", "vocals", "drums", "keys", "commented"]; function formatDate(iso: string): string { - const d = new Date(iso + "T12:00:00"); + const d = new Date(iso.slice(0, 10) + "T12:00:00"); return d.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" }); } function formatDateLabel(iso: string): string { - const d = new Date(iso + "T12:00:00"); + const d = new Date(iso.slice(0, 10) + "T12:00:00"); const today = new Date(); today.setHours(12, 0, 0, 0); const diffDays = Math.round((today.getTime() - d.getTime()) / (1000 * 60 * 60 * 24)); diff --git a/web/src/pages/SessionPage.tsx b/web/src/pages/SessionPage.tsx index e2e8173..7adab04 100644 --- a/web/src/pages/SessionPage.tsx +++ b/web/src/pages/SessionPage.tsx @@ -24,7 +24,7 @@ interface SessionDetail { } function formatDate(iso: string): string { - const d = new Date(iso + "T12:00:00"); + const d = new Date(iso.slice(0, 10) + "T12:00:00"); return d.toLocaleDateString(undefined, { weekday: "long", year: "numeric", month: "long", day: "numeric" }); }