".format("%.02d")" working in simulator but not on device.

I haven't changed the script for this, but after making a new build last night once on device my time string look like
1:1
instead of
01:01

var timeString;
var clockTime = Sys.getClockTime();
if (Sys.getDeviceSettings().is24Hour == true){
timeString = Lang.format("$1$:$2$", [clockTime.hour.format("%.02d"), clockTime.min.format("%.02d")]);
}
else{
timeString = Lang.format("$1$:$2$", [(clockTime.hour % 12), clockTime.min.format("%.02d")]);
}



  • This has been hashed out several times. This sticky post covers the solution.
  • question

    This seems an okay place to ask,

    How can I search the developer forum (only) for keywords? I do not know how to do this very well at all!

    Even a few tips would beat the heck out of trying to read all XX pages and keep another twenty pages open...


    Thanks in advance!
  • Yeah I searched multiple times today.
    Thanks for the link.
  • I don't know what to say, but this does not work with the most recent version. I have tried.
    %.2d and %02d and %.02d

    None of these are working.

    %.02d worked for everything until this new update.

    Can someone else verify?
  • From what I make of the different sources of information, I believe the one without the decimals will work. However, I have not tested it yet; sorry. And I'm also new to this.
  • Searching forums / advanced search

    Hi all,

    I just figured it out!!! This may be useful! In order to search JUST the connect IQ forums, here's what we have to do.

    (1) click on the "advanced search" link in the top right-hand corner of the Garmin forum.

    (2) You should see the normal search window in front of you now. There should be two blue tabs at the top: one says "Search Single Content Type" and the other says "Search Multiple Content Types". Beneath that next to "Search Types:" there is either a dropdown selection box, or three checkboxes.

    --(If next to "Search Types:", your screen shows a dropdown menu selection box listing "Forums" and "Post", go on to the next step)
    --If on the other hand yours shows three checkboxes, you want the page to re-load, with a dropdown menu selection box - so try clicking on the blue tabs some. Click one blue tab then click the other to go back; The "search single content type" tab should be highlighted when you're done. And hopefully after you've done this, it shows a dropdown menu selection box there.

    (3) Next to "Search Types:" select "Posts" from the dropdown menu box. Once you do that, you can take a peek at the attached screenshot to look at the rest of the details, or just keep reading the instructions.

    ---

    (4) From the "Search in Forums" box, select "Connect IQ"
    (5) Uncheck "Also search in child forums".
    (6) Enter "1" or whatever number you want in the "Find posts with at least __" replies box.
    (7) Be sure to click "Go" next to "Save search preferences" at the bottom left to save those settings!
    (8) Finally, enter your search term(s) in the "Keyword(s)" box and click search.
  • %.02d worked for everything until this new update.

    I'm sorry, but it doesn't matter if it did work or not. It was never intended to work, and Garmin has said that %02d is the correct format. You should use that.

    Can someone else verify?

    You're going to need to provide some more detail. What device? What firmware? What SDK version did you use?

    I'm using 1.2.2 SDK on a vivoactive, fr630 and fr920xt (all with latest firmware) and I do not see the problem when using %02d (no period). The fr630 happens to work with all of the formats I tested (%02d, %.2d, %0.2d, %.02d) but only %02d works on the other devices.

    Travis
  • using 1.2.2 with eclipse mars, device is 920xt running 6.20
    var timeString;
    var clockTime = Sys.getClockTime();
    if (Sys.getDeviceSettings().is24Hour == true){
    timeString = Lang.format("$1$:$2$", [clockTime.hour.format("%02d"), clockTime.min.format("%02d")]);
    }
    else{
    timeString = Lang.format("$1$:$2$", [(clockTime.hour % 12), clockTime.min.format("%02d")]);
    }

    does not work as you have described.
    I am still seeing 09:09 show up as 9:9

    Thanks for your help there Travis, I know it can be frustrating.
  • Something else is going on. I too am using a fr920xt with v6.2.0 firmware, and I'm using the 1.2.2 SDK on Eclipse Luna. It works on exactly like I'm expecting.

    I could send you my test widget and we can compare what we see?
  • var timeString;
    var clockTime = Sys.getClockTime();
    if (Sys.getDeviceSettings().is24Hour == true){
    timeString = Lang.format("$1$:$2$", [clockTime.hour.format("%02d"), clockTime.min.format("%02d")]);
    }
    else{
    timeString = Lang.format("$1$:$2$", [(clockTime.hour % 12), clockTime.min.format("%02d")]);
    }



    I noticed that in your !is24Hour code, and will result in a display of "0" when it should show "12".
    Instead of just the %12, you need something like this:

    hour = clockTime.hour % 12;
    hour = (hour == 0) ? 12 : hour;


    (if hr=0, make it 12.... In 12hr mode, there is 12am and 12pm, but no 0)