You are reading a single comment by @RaoulDuke and its replies. Click here to read the full conversation.
  • I changed the code to this:

    setTimeout(function() {
      setInterval(draw,60000);
    }, 60000 - Date.now() % 60000);
    

    I also put this line in draw() to measure the timing error:

    g.setFontAlign(0,1).drawString(parseInt(((Date.now()+30000)%60000)-30000)/1000,g.getWidth()/2,24+18);
    

    So far it has never shown more than 0.01s, which is good enough for a clock that updates every minute.

About

Avatar for RaoulDuke @RaoulDuke started