fix: show actual timestamps in debug log viewer

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 <noreply@anthropic.com>
This commit is contained in:
2026-02-23 16:02:28 +01:00
parent 1183a29d3e
commit 4edc974404
2 changed files with 6 additions and 6 deletions
+2 -1
View File
@@ -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] == ' ' {
+4 -5
View File
@@ -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');