From c6934214b48228d0b412706f80e746c18a42d141 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sun, 9 Jun 2024 02:08:53 +1200 Subject: [PATCH] format uptime seconds --- src/public/index.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/public/index.html b/src/public/index.html index 15feb55..df29df7 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -852,7 +852,7 @@

Uptime

- {{ selectedNode.uptime_seconds }} seconds + {{ formatUptimeSeconds(selectedNode.uptime_seconds) }} ???

@@ -2452,6 +2452,15 @@ window._onHideNodeNeighboursClick(); this.selectedNodeToShowNeighbours = null; }, + formatUptimeSeconds: function(secondsToFormat) { + secondsToFormat = Number(secondsToFormat); + var days = Math.floor(secondsToFormat / (3600 * 24)); + var hours = Math.floor((secondsToFormat % (3600 * 24)) / 3600); + var minutes = Math.floor((secondsToFormat % 3600) / 60); + var seconds = Math.floor(secondsToFormat % 60); + var daysPlural = days === 1 ? 'day' : 'days'; + return `${days} ${daysPlural} ${hours}h ${minutes}m ${seconds}s`; + }, }, computed: { searchedNodes() {