Fixed problem with clock in 12-hour display
This commit is contained in:
+5
-3
@@ -806,8 +806,6 @@ void showCT() {
|
|||||||
|
|
||||||
// Format the time based on region
|
// Format the time based on region
|
||||||
if (radio.rds.region == 1) { // USA region: 12-hour AM/PM format
|
if (radio.rds.region == 1) { // USA region: 12-hour AM/PM format
|
||||||
strftime(str, sizeof(str), "%I:%M", localtime(&t));
|
|
||||||
|
|
||||||
// Determine AM/PM and adjust hour format
|
// Determine AM/PM and adjust hour format
|
||||||
int hour = localtime(&t)->tm_hour;
|
int hour = localtime(&t)->tm_hour;
|
||||||
String ampm = (hour >= 12) ? "PM" : "AM";
|
String ampm = (hour >= 12) ? "PM" : "AM";
|
||||||
@@ -817,7 +815,11 @@ void showCT() {
|
|||||||
hour -= 12; // Convert PM hours
|
hour -= 12; // Convert PM hours
|
||||||
}
|
}
|
||||||
|
|
||||||
rds_clock = String(hour) + ":" + String(localtime(&t)->tm_min) + " " + ampm;
|
// Format the time string with leading zeros for minutes
|
||||||
|
char formattedTime[10];
|
||||||
|
sprintf(formattedTime, "%d:%02d %s", hour, localtime(&t)->tm_min, ampm.c_str());
|
||||||
|
|
||||||
|
rds_clock = String(formattedTime);
|
||||||
} else { // Other regions: 24-hour format
|
} else { // Other regions: 24-hour format
|
||||||
strftime(str, sizeof(str), "%H:%M", localtime(&t));
|
strftime(str, sizeof(str), "%H:%M", localtime(&t));
|
||||||
rds_clock = String(str);
|
rds_clock = String(str);
|
||||||
|
|||||||
Reference in New Issue
Block a user