From ab5f2e953c4e05770c60486c998262f66a30353d Mon Sep 17 00:00:00 2001 From: Bufo Date: Fri, 27 Sep 2024 20:48:24 +0200 Subject: [PATCH] feat: add 0 prefix to single digit hours --- src/lib/screen_handler.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/screen_handler.cpp b/src/lib/screen_handler.cpp index d1c6165..a8d75f0 100644 --- a/src/lib/screen_handler.cpp +++ b/src/lib/screen_handler.cpp @@ -82,12 +82,19 @@ void workerTask(void *pvParameters) { std::string timeString; String minute = String(timeinfo.tm_min); + String hour = String(timeinfo.tm_hour); + + if (hour.length() < 2) { + hour = "0" + hour; + } if (minute.length() < 2) { minute = "0" + minute; } - timeString = - std::to_string(timeinfo.tm_hour) + ":" + minute.c_str(); + timeString = timeString.append(hour.c_str()); + timeString = timeString.append(String(":").c_str()); + timeString = timeString.append(minute.c_str()); + timeString.insert(timeString.begin(), NUM_SCREENS - timeString.length(), ' '); taskEpdContent[0] = std::to_string(timeinfo.tm_mday) + "/" +