Duration of ")" incorrect in Number Picker (vivoactive)

The ")" above should be "0" but it doesn't seem I can edit that part of the post!

I'm using a Number Picker to set a timer value on the vivoactive in an app. To initialize it, I have a value of "timerValue" in seconds.

I convert it into a Duration, and then fire up the number picker. In the simulator, all is fine, but on the device, it has an initial value of 1 second!

Here's the code (timerValue is 0 at this point)
hr=timerValue/(3600);
min= (timerValue-(hr*3600))/60;
sec= timerValue%60;
Sys.println(hr+":"+min+":"+sec);
dur = Calendar.duration( {:hours=>hr, :minutes=>min, :seconds=>sec} );
Sys.println("dur="+dur.value());
//for up to 8hrs
np = new Ui.NumberPicker( Ui.NUMBER_PICKER_TIME, dur );
Ui.pushView( np, new NPTimer(), Ui.SLIDE_IMMEDIATE );


In both the simulator and on the device itself, the output from the println()'s are:
0:0:0
dur=0

If I have a non zero value in timerValue, it works fine....

update: on the real device, I can't set it to zero seconds, unless hour or minute is non zero.... So there is no way to set a zero duration on the va, but it's allowed in the simulator. I use a returned duration of "0" to specify the timer isn't used...
  • So to be clear, the following code would have been sufficient to illustrate the problem and would have been a little less confusing...

    var duration = Calendar.duration( {:hours => 0, :minutes => 0, :seconds => 0 } );
    var picker = new Ui.NumberPicker( Ui.NUMBER_PICKER_TIME, duration );
    Ui.pushView( picker, ..., Ui.SLIDE_IMMEDIATE );


    If that is the case, then it seems like a bug. The picker should be able to represent a duration of zero seconds.

    I'm curious. Is there some reason that you are breaking down timerValue into hours, minutes and seconds, only to reconstitute it as a duration? Assuming that timerValue is a number of seconds, it seems that you could have more simply written...

    var duration = new Time.Duration( timerValue );


    Travis
  • the only reason I break it down is that I stole code from someplace else that did it as separate values! :)

    Yes, with your simpler code, it still won't allow a duration of 0:00:00 on the vivoactive
  • Thanks for the report! I've filed this as a bug to be investigated.