[..BUG]info.startTime on 920xt

Former Member
Former Member
I have a simple datafield that displays the activity start time. Works fine in simulator, but on 920xt I get a value 20 years, minus 1 day ago.

function compute(info) {
if (info.startTime == null)
{
return "---";
}
else
{
var i = Time.Gregorian.info(info.startTime, Time.FORMAT_SHORT);
return Lang.format("$1$-$2$-$3$ $4$:$5$:$6$", [i.year, i.month, i.day, i.hour, i.min, i.sec]);
}
}


I would like for someone from Garmin to confirm this as being a bug and I'd like to know if the bug is only on the 920xt or also on other devices. (I have an app in the store that is effected by this bug.)
  • 20 years minus 1 day is exactly the difference between the Garmin epoch and the unix epoch.

    Unix epoch is Jan 1, 1970. Garmin epoch is Dec 31, 1989.

    This has been discussed here https://forums.garmin.com/showthread.php?169075-Limits-for-Gregorian-time-values

    and here. https://forums.garmin.com/showthread.php?203321-Generic-ANT-Sample-Code-Tweaks

    I'm not sure what the functionality is supposed to be with the functions you are using. Is it acting differently between the watch and the simulator?
  • Is it acting differently between the watch and the simulator?


    Works fine in simulator, but on 920xt I get a value 20 years, minus 1 day ago.


    Yes, it looks like he is saying the simulator behaves differently than the device. The issue could be that the returned time value is offset, or that the Gregorian module isn't taking the offset into account. It isn't clear which it is, but a test that printed the broken-down time for 0 would determine get the answer.
  • Just for more information, the following code sets the correct time on a Moxy sensor when it's run on the simulator and when it's run on a 920XT watch.

    function setTime()
    {
    if( !searching
    && ( data.utcTimeSet ) )
    {
    //Create and populat the data payload
    var payload = new [8];
    payload[0] = 0x10; //Command data page
    payload[1] = 0x00; //Set time command
    payload[2] = 0xFF; //Reserved
    payload[3] = 0; //Signed 2's complement value indicating local time offset in 15m intervals

    //Set the current time
    var moment = Time.now();
    var secsGarEpoch = moment.value() - 631065600;
    payload[4] = secsGarEpoch % 256;
    payload[5] = (secsGarEpoch / 256) % 256;
    payload[6] = (secsGarEpoch / 65536) % 256;
    payload[7] = (secsGarEpoch / 16777216) % 256;

    //Form and send the message
    var message = new Ant.Message();
    message.setPayload(payload);
    GenericChannel.sendAcknowledge(message);
    }
    }


    This means that Time.now returns the correct time relative to the Unix epoch in both the watch and the simulator which seems to be the documented functionality for moments.

    From: Toybox/Time/Moment.html
    The Moment object represents an immutable moment in time. Internally stored as a 32 bit integer of number of seconds since the UNIX epoch.


    Not sure if this information is relevant to the problem above, but thought I'd share if it would help.
  • Former Member
    Former Member over 10 years ago
    Yes, it looks like he is saying the simulator behaves differently than the device. The issue could be that the returned time value is offset, or that the Gregorian module isn't taking the offset into account. It isn't clear which it is, but a test that printed the broken-down time for 0 would determine get the answer.


    The error is in the time value. If you start the timer and then take the duration in seconds between info.startTime and Time.now(), you get the 20 years minus 1 day value.
  • Former Member
    Former Member over 10 years ago
    It appears the startTime value is not being filled in on the device. We will look into the issue.