I do use following code to calculate the data for the time display in my watchface:var clockTime = System.getClockTime();// returns [hour, sep, min, amPm]var time = CoreUtils.formatTime(setup, clockTime.hour, clockTime.min, /* forceNoAmPm */ true);// ... just displaying the parts from the time arrayCode
My format function is following:static function formatTime(setup, hour, min, forceNoAmPm) { var amPm = ""; if (!System.getDeviceSettings().is24Hour) { var isPm = (hour >= 12); if (isPm) { if (hour > 12) { hour = hour - 12; } amPm = "p"; } else { if (hour == 0) { hour = 12; } amPm = "a"; } } var showAmPm = setup.checkBit(3 /* BIT_SHOW_AM_PM */); if (!showAmPm || forceNoAmPm) { amPm = ""; } var showLeadingZero = setup.checkBit(5 /* BIT_SHOW_LEADING_ZERO */); hour = hour.format(showLeadingZero ? "%02d" : "%d"); var sep = ":"; var useMilitaryFormat = setup.checkBit(2 /* BIT_USE_MILITARY */); if (useMilitaryFormat) { sep = ""; } return [hour, sep, min.format("%02d"), amPm];}
Is there anything wrong in this code? I use this for nearly a year now without problems, yesterday someone from alaska wrote me the time in my watchface is 12h off... Is there something wrong with my code? System.getClocktime() does give me the devices time in the timezone that the watch is set up, so I don't see any issue in my code. The user reports that he does not have this problem with other watchfaces...
Does anyone see the problem?