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:
@@ -111,8 +111,9 @@ func parseLine(line string) LogEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to parse timestamp: "2006/01/02 15:04:05"
|
// 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 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
|
entry.Timestamp = t
|
||||||
rest := line[19:]
|
rest := line[19:]
|
||||||
if len(rest) > 0 && rest[0] == ' ' {
|
if len(rest) > 0 && rest[0] == ' ' {
|
||||||
|
|||||||
@@ -698,12 +698,11 @@ function fmtTime(ts) {
|
|||||||
if (!ts) return '-';
|
if (!ts) return '-';
|
||||||
var d = new Date(ts);
|
var d = new Date(ts);
|
||||||
if (isNaN(d.getTime())) return ts;
|
if (isNaN(d.getTime())) return ts;
|
||||||
|
var pad = function(n) { return n < 10 ? '0' + n : n; };
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var diff = Math.floor((now - d) / 1000);
|
var time = pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds());
|
||||||
if (diff < 60) return diff + 'mp';
|
if (d.toDateString() === now.toDateString()) return time;
|
||||||
if (diff < 3600) return Math.floor(diff/60) + 'p';
|
return pad(d.getMonth()+1) + '-' + pad(d.getDate()) + ' ' + time;
|
||||||
if (diff < 86400) return Math.floor(diff/3600) + 'ó ' + Math.floor((diff%3600)/60) + 'p';
|
|
||||||
return d.toLocaleString('hu-HU');
|
|
||||||
}
|
}
|
||||||
function escapeHtml(s) {
|
function escapeHtml(s) {
|
||||||
var d = document.createElement('div');
|
var d = document.createElement('div');
|
||||||
|
|||||||
Reference in New Issue
Block a user