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 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.)

Comment
  • > 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.)

Children
No Data