From fece84350527e05d4275b9913efe4d614ef1a5ff Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 7 Jul 2025 14:14:05 +0200 Subject: [PATCH] Fix date format issues in events API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convert Unix timestamps to ISO strings before sending to frontend - Store dates as ISO strings in database during event creation - Fix created_at, expires_at, and archived_at date conversions This resolves the "Invalid time value" error that occurred when viewing the events page due to SQLite returning dates as Unix timestamps. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/src/routes/adminEvents.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/src/routes/adminEvents.js b/backend/src/routes/adminEvents.js index 797014a..c98002b 100644 --- a/backend/src/routes/adminEvents.js +++ b/backend/src/routes/adminEvents.js @@ -77,8 +77,8 @@ router.post('/', adminAuth, [ welcome_message, color_theme, share_link: shareLink, - expires_at, - created_at: new Date() + expires_at: expires_at.toISOString(), + created_at: new Date().toISOString() }); // Log activity @@ -180,10 +180,14 @@ router.get('/', adminAuth, async (req, res) => { return acc; }, {}); - // Add photo counts to events + // Add photo counts to events and convert dates const eventsWithCounts = events.map(event => ({ ...event, - photo_count: photoCountMap[event.id] || 0 + photo_count: photoCountMap[event.id] || 0, + // Convert Unix timestamps to ISO strings + created_at: event.created_at ? new Date(event.created_at).toISOString() : null, + expires_at: event.expires_at ? new Date(event.expires_at).toISOString() : null, + archived_at: event.archived_at ? new Date(event.archived_at).toISOString() : null })); res.json({