Merge pull request #176 from ekimekim/mike/update-clock

Update clock.html for 2020 and display negative time properly
pull/177/head
Mike Lang 4 years ago committed by GitHub
commit 239fc5d9ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,7 +1,7 @@
<html>
<script>
delay = 10;
bustime = 1573228800;
bustime = 1605290400;
function update() {
delay = parseInt(document.getElementById("Delay").value);
@ -9,12 +9,17 @@ function update() {
setInterval(function() {
var time = new Date().getTime() / 1000 - delay - bustime;
var minus = "";
if (time < 0) {
time = -time
minus = "-";
}
var hours = Math.trunc(time / 3600).toString();
var mins = Math.trunc((time % 3600) / 60).toString();
var secs = Math.trunc(time % 60).toString();
if (mins.length < 2) {mins = "0" + mins;}
if (secs.length < 2) {secs = "0" + secs;}
var formatted = hours + ":" + mins + ":" + secs;
var formatted = minus + hours + ":" + mins + ":" + secs;
document.getElementById("Clock").value = formatted;
}, 1000);
</script>

Loading…
Cancel
Save