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; }

Parents
  • 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; }
    }

Comment
  • 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; }
    }

Children
No Data