From d046a6f4fdcbae6f24606269b5f85bd45261f890 Mon Sep 17 00:00:00 2001 From: Richard Bergsma Date: Mon, 7 Jul 2025 20:11:22 +0200 Subject: [PATCH] Add temporary debug logging to formatLocalTime function in UptimeStatusIsland - Introduced console logging for various stages of date parsing to assist in production debugging. - Enhanced error handling to log failures during ISO and format parsing attempts. - Maintained existing functionality while providing insights into the parsing process. --- src/components/UptimeStatusIsland.jsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/UptimeStatusIsland.jsx b/src/components/UptimeStatusIsland.jsx index 5a78e80..b470bdc 100644 --- a/src/components/UptimeStatusIsland.jsx +++ b/src/components/UptimeStatusIsland.jsx @@ -48,22 +48,27 @@ function getUptime24hBg(uptime) { function formatLocalTime(rawTime, zone = 'utc') { if (!rawTime) return ''; + // Temporary production debug logging + console.log('PROD DEBUG - Raw time:', rawTime, 'Zone:', zone); + let dt = null; // First try ISO parsing (most reliable for UTC timestamps) try { dt = DateTime.fromISO(rawTime, { zone: 'utc' }); if (dt.isValid) { + console.log('PROD DEBUG - ISO parsing successful:', dt.toISO()); // If target zone is UTC, return as-is if (zone === 'utc') { return dt.toFormat('dd-MM-yyyy, HH:mm:ss'); } // Otherwise convert to target timezone const converted = dt.setZone(zone); + console.log('PROD DEBUG - Converted to zone:', converted.toISO()); return converted.isValid ? converted.toFormat('dd-MM-yyyy, HH:mm:ss') : 'Invalid DateTime'; } } catch (e) { - // Continue to format parsing if ISO fails + console.log('PROD DEBUG - ISO parsing failed:', e.message); } // Try various formats, always assuming incoming time is UTC @@ -79,7 +84,10 @@ function formatLocalTime(rawTime, zone = 'utc') { for (const format of formats) { try { dt = DateTime.fromFormat(rawTime, format, { zone: 'utc' }); - if (dt.isValid) break; + if (dt.isValid) { + console.log('PROD DEBUG - Format parsing successful:', format, dt.toISO()); + break; + } } catch (e) { continue; } @@ -91,13 +99,15 @@ function formatLocalTime(rawTime, zone = 'utc') { const jsDate = new Date(rawTime); if (!isNaN(jsDate.getTime())) { dt = DateTime.fromJSDate(jsDate, { zone: 'utc' }); + console.log('PROD DEBUG - JS Date parsing successful:', dt.toISO()); } } catch (e) { - // Give up + console.log('PROD DEBUG - JS Date parsing failed:', e.message); } } if (!dt || !dt.isValid) { + console.log('PROD DEBUG - All parsing failed for:', rawTime); return 'Invalid DateTime'; }