From 4edc9744044adaeb4f86ee16d170d1e225c50dc3 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Mon, 23 Feb 2026 16:02:28 +0100 Subject: [PATCH] fix: show actual timestamps in debug log viewer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Naplóviewer was showing relative times like '3586mp' (seconds ago) which were also negative due to timezone mismatch — parseLine used time.Parse (UTC) but log.LstdFlags outputs local time. Now: - parseLine uses time.ParseInLocation with time.Local - fmtTime JS shows absolute HH:MM:SS (or MM-DD HH:MM:SS for old entries) Co-Authored-By: Claude Opus 4.6 --- controller/internal/web/logbuffer.go | 3 ++- controller/internal/web/templates/debug.html | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controller/internal/web/logbuffer.go b/controller/internal/web/logbuffer.go index 7e18a7d..a656383 100644 --- a/controller/internal/web/logbuffer.go +++ b/controller/internal/web/logbuffer.go @@ -111,8 +111,9 @@ func parseLine(line string) LogEntry { } // Try to parse timestamp: "2006/01/02 15:04:05" + // Use Local timezone because Go's log.LstdFlags outputs in local time. if len(line) >= 19 { - if t, err := time.Parse("2006/01/02 15:04:05", line[:19]); err == nil { + if t, err := time.ParseInLocation("2006/01/02 15:04:05", line[:19], time.Local); err == nil { entry.Timestamp = t rest := line[19:] if len(rest) > 0 && rest[0] == ' ' { diff --git a/controller/internal/web/templates/debug.html b/controller/internal/web/templates/debug.html index 8a75d69..08b2dff 100644 --- a/controller/internal/web/templates/debug.html +++ b/controller/internal/web/templates/debug.html @@ -698,12 +698,11 @@ function fmtTime(ts) { if (!ts) return '-'; var d = new Date(ts); if (isNaN(d.getTime())) return ts; + var pad = function(n) { return n < 10 ? '0' + n : n; }; var now = new Date(); - var diff = Math.floor((now - d) / 1000); - if (diff < 60) return diff + 'mp'; - if (diff < 3600) return Math.floor(diff/60) + 'p'; - if (diff < 86400) return Math.floor(diff/3600) + 'ó ' + Math.floor((diff%3600)/60) + 'p'; - return d.toLocaleString('hu-HU'); + var time = pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()); + if (d.toDateString() === now.toDateString()) return time; + return pad(d.getMonth()+1) + '-' + pad(d.getDate()) + ' ' + time; } function escapeHtml(s) { var d = document.createElement('div');