Acknowledged
CIQQA-3846

Bug in watchface template: 12-hour mode shows "0:00" at midnight

When creating a new project via Monkey C: New Project > Watch Face > Simple with Settings (min API 1.2.0, device fr55), the generated onUpdate() in the View has this 12-hour conversion:


if (hours > 12) {
hours = hours - 12;
}


This doesn't handle midnight (hour = 0 from getClockTime()). Since 0 > 12 is false, the watch displays 0:00 instead of 12:00.

Steps to reproduce:

Create a new project: Monkey C: New Project > Name > Watch Face > Simple with Settings > 1.2.0 > fr55
Build and run in simulator
Set device to 12-hour format
Set simulated time to 00:00 (midnight)
Watch face displays "0:00" instead of "12:00"


Fix:


hours = hours % 12;
if (hours == 0) { hours = 12; }

  • > I think you misunderstand what the samples are for. They are not to teach you general programming or algorithms

    In the same vein, the samples are also not here to:

    - show people how to do things incorrectly

    - provide default / boilerplate functionality that's incorrect

    At least they shouldn't be imo.

    I feel like it's better to leave out functionality than do it blatantly wrong, especially when one of the more correct alternatives is nearly as simple as the existing code.

    The template doesn't even have to support the 24 hour clock setting (although that would be nice) - at the very least it could implement the 12 hour clock properly. (Ofc if Garmin had to choose between 12 and 24 h, they would choose 12 h, since Garmin is an American company and it seems that their primary focus in the American market.)

  • I agree that samples are meant to demonstrate SDK usage, not teach general programming. But I'd argue this is still worth fixing precisely because it's a template — developers start new projects from it and may not notice the midnight bug until a user reports it. A one-line fix (hours = hours % 12; if (hours == 0) { hours = 12; }) would make the template correct out of the box.

    I'd also add that including proper 24h support wouldn't hurt. Garmin watches support it, System.getDeviceSettings().is24Hour is a CIQ API, and most Garmin users outside the US use 24-hour format. If the purpose of the template is to show how to use SDK classes, why not show this one too? It's two extra lines:

    if (!System.getDeviceSettings().is24Hour) {
    hours = hours % 12;
    if (hours == 0) { hours = 12; }
    }

  • Man, you're not wrong in the things you wrote, I agree even that the -12 vs %12 is a bug, but I think you misunderstand what the samples are for. They are not to teach you general programming or algorithms. They are to show how to use the Garmin/CIQ specific classes in the SDK.

    Maybe what you're looking for is some real watch face in GitHub?

  • Additionally, the template could support 24-hour format. The current code unconditionally converts to 12-hour, but Garmin devices expose System.getDeviceSettings().is24Hour which should be respected. A proper implementation would be:


    if (!System.getDeviceSettings().is24Hour) {
    hours = hours % 12;
    if (hours == 0) { hours = 12; }
    }


    This both fixes the midnight bug and honors the user's 24-hour preference from device settings.