From c9cc34d421cef05b2309ed3aa142a3536da8cc14 Mon Sep 17 00:00:00 2001 From: "protostatis.dev" Date: Wed, 19 Aug 2026 11:08:27 -0500 Subject: [PATCH] fix: render News briefing date in UTC to stop day-behind headline The trending `date` field is a calendar date only (e.g. "2026-07-24"). `new Date("2026-07-24")` parses it as UTC midnight, and toLocaleDateString then shifts it into the viewer's timezone, rolling the calendar day back by one in any timezone west of UTC (e.g. US Central). Format in UTC so the displayed day matches the stored date. --- dashboard-frontend/src/pages/News.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dashboard-frontend/src/pages/News.jsx b/dashboard-frontend/src/pages/News.jsx index a68201e..3129c0d 100644 --- a/dashboard-frontend/src/pages/News.jsx +++ b/dashboard-frontend/src/pages/News.jsx @@ -19,12 +19,19 @@ const NEWSLETTER_URL = 'https://panicradar.substack.com'; const formatCalendarDate = (dateStr) => { if (!dateStr) return null; - const date = new Date(dateStr); + // The backend `date` field is a calendar date only (e.g. "2026-07-24"), + // not an instant. `new Date("2026-07-24")` parses it as UTC midnight, and + // toLocaleDateString then shifts it into the viewer's timezone — which rolls + // the calendar day back by one in any timezone west of UTC (e.g. US Central). + // Format in UTC so the displayed calendar day always matches the stored date. + const isDateOnly = /^\d{4}-\d{2}-\d{2}$/.test(dateStr); + const date = new Date(isDateOnly ? `${dateStr}T00:00:00Z` : dateStr); if (Number.isNaN(date.getTime())) return null; return date.toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', + timeZone: 'UTC', }); };