From 246133cbd44412cd4571bef599a6023d52bc8bad Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 1 Nov 2026 20:15:29 +0100 Subject: dashboard: 24h-clock --- src/api/dashboard/dashboard.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/api') diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html index 6a365a8..f31808d 100644 --- a/src/api/dashboard/dashboard.html +++ b/src/api/dashboard/dashboard.html @@ -1701,6 +1701,9 @@ function trafficArrived() { // every update (the same counts as the map's messages), the latest at the bottom, // `CONSOLE_LINES` at most. Scrolled along while at the bottom. --- const CONSOLE_LINES = 200; +// A time of day on the 24-hour clock, whatever the browser's locale: 18:04:05. +const clockTime = date => [date.getHours(), date.getMinutes(), date.getSeconds()] + .map(part => String(part).padStart(2, "0")).join(":"); const size = bytes => bytes < 1024 ? bytes + " B" : bytes < 1048576 ? (bytes / 1024).toFixed(1) + " KiB" : (bytes / 1048576).toFixed(1) + " MiB"; // The lines, kept while the box is collapsed and drawn when it's opened (`showConsole`). @@ -1716,7 +1719,7 @@ function consoleLine([when, text, kinds]) { } function logTraffic(way, peer, total, kinds) { const bytes = Object.values(kinds).reduce((sum, grown) => sum + grown.bytes, 0); - const line = [new Date().toLocaleTimeString(), + const line = [clockTime(new Date()), (way === "sent" ? "→ " : "← ") + name(peer) + ": " + total + ", " + size(bytes), Object.entries(kinds).map(([kind, grown]) => [kind, grown.messages])]; consoleLines.push(line); -- cgit v1.3.1