Ok, I am trying to figure out how to switch from 12 to 24 hours based on the watch's settings. My plan is that if the watch is set at 12 hour, it will just display something like 1:30 (for day or night) and if it's set for 24 hours, it will display 1330 for 1:30pm.
I have been trying to figure out how to do it for the past several days but can't get it to work. The 24 hour time works fine, but the 12 hour is screwing up. It displays 12 midnight as 0:00 instead of 12:00 and 1pm as 13:00.
My lines are obviously wrong somewhere and I am wondering if anyone can take a look at it and see where it bust?
Much thanks in advance.
View.onUpdate(dc);
dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
var clockTime = Sys.getClockTime();
var hour = clockTime.hour;
var sys = Sys.getDeviceSettings().is24Hour;
if (sys==false) {
if (hour > 12) {
hour = hour - 12;
if (hour == 0) {hour = 12;}
}
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.drawText(0, 100, Gfx.FONT_LARGE, Lang.format("$1$:$2$", [clockTime.hour, clockTime.min.format("%02d")]), Gfx.TEXT_JUSTIFY_LEFT);
} else {
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.drawText(0, 100, Gfx.FONT_LARGE, Lang.format("$1$$2$", [clockTime.hour.format("%02d"), clockTime.min.format("%02d")]), Gfx.TEXT_JUSTIFY_LEFT);
}