diff --git a/assets/js/time.js b/assets/js/time.js index b79eda7a8..e295c29be 100644 --- a/assets/js/time.js +++ b/assets/js/time.js @@ -3,11 +3,23 @@ // ┴ ┴┴ ┴└─┘ // Set time and Date +let last_saved_minute = 61; window.onload = displayClock(); + function displayClock() { - const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + writeTime() + setInterval(() => { + let d = new Date(); + if(d.getMinutes() == last_saved_minute) return; + last_saved_minute = d.getMinutes() + writeTime() + },1000); +} - var d = new Date(); +function writeTime() { + let d = new Date(); + const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + var mm = monthNames[d.getMonth()]; var dd = d.getDate(); var min = (mins = ('0' + d.getMinutes()).slice(-2)); @@ -26,6 +38,4 @@ function displayClock() { document.getElementById('month').innerText = mm; document.getElementById('day').innerText = dd; - - setTimeout(displayClock, 1000); -} +} \ No newline at end of file