Countdown timer on WatchFace out of sync with clock

Hi,

I have discovered some inconsistencies with keeping a countdown timer in sync with the clock on a watchface.

What I do is to display the clock time at the top of the watchface, and below that, the remaining days, hours and minutes to a specific date in the future (hard coded Moment at this stage)

So I get the now Moment, and then subtract it from the future event Moment to get a difference.
From this I calculate the remaining days, hours and minutes and update the label on the view.

But, I have found that testing this in the simulator works as expected. The clock and countdown timer's values match.
E.g. if the clock is 09:58

And the future event is at 11:00

The count down timer displays

0 days
1 hour
2 minutes

But when I run it on the actual watch itself, the count down timer always has the minutes out of sync and would display
0 days
1 hour
3 minutes

I have also found that when I set the watch time manually in order to test on the watch, it still seem to get the wrong clock time (not the manually entered time, but the GPS time).

I have read another post about the onUpdate and the seconds being forced to 00. I am wondering if my issue has got something to do with this?

It is really confusing.

H
  • time.hour = 1 + (time.hour + 11) % 12;


    what's the reason for doing the above?
    I removed the 1 and the 11 and just used time.hour%12 and get the same result.
  • time.hour = 1 + (time.hour + 11) % 12;


    what's the reason for doing the above?
    I removed the 1 and the 11 and just used time.hour%12 and get the same result.


    Looks kind of like a conversion to 12 hr..

    I use
    hour = today.hour % 12;
    hour = (hour == 0) ? 12 : hour;

    myself! It works fine... :) And easy to understand when you look at the code years from now...
  • hi Jim - I use the same for the 12/24 hour thing as well. (I just fixed all my apps - well, majority anyways)

    Travis - I wanna thank you for your piece of code. Been banging my head on the wall over the "added" time.
    I kept seeing 8 hours difference.
    I tried

    var now = Time.now()
    var now1 = Time.today()


    now returns the current time
    now1 always kept returning 8:00 (which after a lot of head banging) figured it out to be the TimeOffset based on where I am physically. UTC+8

    so, this code of yours was the saviour

    eventMoment = eventMoment.add(new Time.Duration(-Sys.getClockTime().timeZoneOffset));
  • Former Member
    Former Member over 10 years ago
    time.hour = 1 + (time.hour + 11) % 12;


    what's the reason for doing the above?
    I removed the 1 and the 11 and just used time.hour%12 and get the same result.

    It's so that time = 0 will return 12, not 0.
  • I do see a minute error when in low power mode using the above code.


    Hi, I missed out on a lot of this conversation.

    So do you mean that you see the out of sync error that I initially reported, or is it a different error you referring to?
    Which code snippet is it where you see the error? Mine?
    And is this fixed by the other snippets given thereafter?
  • The code from Travis shows this well. It's a "rounding" issue.