Bladeren bron

Clock: 12 hour "midnight format" (#41)

* Clock: 12 hour "midnight format"

- Fixes 12hr clock display using the changes described in the PR in Next-Flip/Momentum-Firmware/issues/317. "00:30" OR "12:30".

* Fix: Replace locale midnight format setting with MNTM

* apply time format changes

* Update nightstand_clock/clock_app.c

---------

Co-authored-by: WillyJL <49810075+Willy-JL@users.noreply.github.com>
Alexander Bays 10 maanden geleden
bovenliggende
commit
6056a3c27f
1 gewijzigde bestanden met toevoegingen van 14 en 8 verwijderingen
  1. 14 8
      nightstand_clock/clock_app.c

+ 14 - 8
nightstand_clock/clock_app.c

@@ -7,6 +7,7 @@
 #include <notification/notification.h>
 #include <notification/notification_messages.h>
 #include <notification/notification_app.h>
+#include <momentum/settings.h>
 
 #include "clock_app.h"
 
@@ -150,15 +151,20 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
         snprintf(
             time_string, TIME_LEN, CLOCK_TIME_FORMAT, curr_dt.hour, curr_dt.minute, curr_dt.second);
     } else {
-        bool pm = curr_dt.hour > 12;
         bool pm12 = curr_dt.hour >= 12;
-        snprintf(
-            time_string,
-            TIME_LEN,
-            CLOCK_TIME_FORMAT,
-            pm ? curr_dt.hour - 12 : curr_dt.hour,
-            curr_dt.minute,
-            curr_dt.second);
+        uint8_t hour = curr_dt.hour;
+
+        LocaleTimeFormat time_format = locale_get_time_format();
+        if(time_format == LocaleTimeFormat12h) {
+            if(hour > 12) {
+                hour -= 12;
+            }
+            if(hour == 0) {
+                hour = momentum_settings.midnight_format_00 ? 0 : 12;
+            }
+        }
+
+        snprintf(time_string, TIME_LEN, CLOCK_TIME_FORMAT, hour, curr_dt.minute, curr_dt.second);
 
         snprintf(
             meridian_string,