mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
secondsTimeSpanToHMS: use modulo operator and padStart
Signed-off-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -29,12 +29,11 @@ const REFRESH_INTERVAL = {
|
||||
clients: 600_000, // 10 min (dashboard)
|
||||
};
|
||||
|
||||
function secondsTimeSpanToHMS(s) {
|
||||
const h = Math.floor(s / 3600); //Get whole hours
|
||||
s -= h * 3600;
|
||||
const m = Math.floor(s / 60); //Get remaining minutes
|
||||
s -= m * 60;
|
||||
return h + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s); //zero padding on minutes and seconds
|
||||
function secondsTimeSpanToHMS(seconds) {
|
||||
const h = Math.floor(seconds / 3600);
|
||||
const m = Math.floor((seconds % 3600) / 60);
|
||||
const s = seconds % 60;
|
||||
return `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function piholeChanged(blocking, timer = null) {
|
||||
|
||||
Reference in New Issue
Block a user