Update clock.html for 2020 and display negative time properly

pull/176/head
Mike Lang 4 years ago
parent d6dbf5512d
commit b248408842

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

Loading…
Cancel
Save