You are reading a single comment by @Numerist and its replies. Click here to read the full conversation.
  • Got any specifics? I can try to do an offset, say 630 ms every 3 hours for starters, if I can understand my watch's code. Or is there a generic way to do that?

    Have you had success?

  • Well my actual code is more complex but the basic idea is this:

    setInterval(function() {
      // adjust by 630 milliseconds
      let adjusted_time = Date.now() - 630;
    
      let delay = 1000 - (adjusted_time % 1000);
      setTimeout(function() {
        setTime((adjusted_time + delay) / 1000);
      }, delay);
    
      // adjust every 3 hours
    }, 3 * 60 * 60 * 1000);
    

    Every 3 hours:

    1. get current watch time
    2. calculate adjusted time
    3. calculate delay until adjusted time is exact second
    4. wait that delay and then set watch time in seconds

    Only one running app must do this or else there will be too much adjustment. I'm currently using code like this in my clock app, but it would be best if it were run in a widget (however I havn't yet learned how to make widgets).

About

Avatar for Numerist @Numerist started