Skip to content

Commit 879fb48

Browse files
Fixed 12H mode displaying 24H times
1 parent e01e616 commit 879fb48

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/displayapp/screens/WatchFaceTrans.cpp

+13-10
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,28 @@ void WatchFaceTrans::Refresh() {
131131
uint8_t minute = dateTimeController.Minutes();
132132
uint8_t second = dateTimeController.Seconds();
133133

134+
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
135+
if (hour == 0) {
136+
ampmChar = "AM";
137+
hour = 12;
138+
} else if (hour == 12) {
139+
ampmChar = "PM";
140+
} else if (hour > 12) {
141+
hour = hour - 12;
142+
ampmChar = "PM";
143+
}
144+
}
145+
134146
lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second);
135147

136148
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
137-
if (currentDate.IsUpdated()) {
149+
if (currentDate.IsUpdated() || ampmChar.IsUpdated()) {
138150
uint16_t year = dateTimeController.Year();
139151
Controllers::DateTime::Months month = dateTimeController.Month();
140152
uint8_t day = dateTimeController.Day();
141153
Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek();
142154
lv_label_set_text_fmt(labelDate, "#ffffff %02d-%02d-%04d#", day, static_cast<uint8_t>(month), year);
143155
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
144-
char ampmChar[3] = "AM";
145-
if (hour == 0) {
146-
hour = 12;
147-
} else if (hour == 12) {
148-
ampmChar[0] = 'P';
149-
} else if (hour > 12) {
150-
hour = hour - 12;
151-
ampmChar[0] = 'P';
152-
}
153156
lv_label_set_text_fmt(labelDay, "#ffffff %s %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar);
154157
} else {
155158
lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek));

src/displayapp/screens/WatchFaceTrans.h

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ namespace Pinetime {
4343
Utility::DirtyValue<uint32_t> stepCount {};
4444
Utility::DirtyValue<bool> notificationState {};
4545
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
46+
// Must be wrapped in a dirty value, since it is displayed in the day but is updated twice a day
47+
Utility::DirtyValue<const char*> ampmChar {"AM"};
4648

4749
lv_obj_t* topBlueBackground;
4850
lv_obj_t* topPinkBackground;

0 commit comments

Comments
 (0)