I am working on a decimal clock (100min₁₀ / hr & 100s₁₀ / min₁₀). The code is skipping decimal seconds (in Firefox and Chrome in Ubuntu 14 & Android). The delay in setTimeout
is 1.
function updateTime() {
var now = new Date()
var h = now.getHours();
var m = now.getMinutes();
var s = now.getSeconds();
document.getElementById('babylonian').innerHTML = h+":"+padDigit(m)+":"+padDigit(s)
document.getElementById('decimal').innerHTML = h + "h" + padDigit( Math.round( ( 100 * m ) / 60) ) + "." + padDigit( Math.round( ( 100 * s ) / 60 ) )
setTimeout(updateTime, 1);
}
function padDigit(i) {
return i<10 ? '0' + i : i
}
updateTime()
The clocks seem to be ticking in sync. I don't understand why.