From e3df04d95cb70d56cf6f3b04a4d4656601c45bd3 Mon Sep 17 00:00:00 2001 From: Felipe Martinez Date: Mon, 29 Dec 2025 23:02:50 +0100 Subject: [PATCH 1/4] Fix DateTime::SetTime logging before initialized --- src/components/datetime/DateTimeController.cpp | 10 ++++++---- src/components/datetime/DateTimeController.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index 2ef0ef22f1..c309968eb5 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -31,7 +31,7 @@ DateTime::DateTime(Controllers::Settings& settingsController) : settingsControll xSemaphoreGive(mutex); // __DATE__ is a string of the format "MMM DD YYYY", so an offset of 7 gives the start of the year - SetTime(compileTimeAtoi(&__DATE__[7]), 1, 1, 0, 0, 0); + SetTime(compileTimeAtoi(&__DATE__[7]), 1, 1, 0, 0, 0, false); } void DateTime::SetCurrentTime(std::chrono::time_point t) { @@ -41,7 +41,7 @@ void DateTime::SetCurrentTime(std::chrono::time_point Date: Tue, 30 Dec 2025 02:31:11 +0100 Subject: [PATCH 2/4] Better way --- .../datetime/DateTimeController.cpp | 20 +++---------------- src/components/datetime/DateTimeController.h | 2 +- src/main.cpp | 4 ++++ src/utility/Math.h | 9 +++++++++ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index c309968eb5..63038636d3 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -14,24 +14,12 @@ namespace { constexpr const char* const MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; constexpr const char* const MonthsStringLow[] = {"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - constexpr int compileTimeAtoi(const char* str) { - int result = 0; - while (*str >= '0' && *str <= '9') { - result = result * 10 + *str - '0'; - str++; - } - return result; - } } DateTime::DateTime(Controllers::Settings& settingsController) : settingsController {settingsController} { mutex = xSemaphoreCreateMutex(); ASSERT(mutex != nullptr); xSemaphoreGive(mutex); - - // __DATE__ is a string of the format "MMM DD YYYY", so an offset of 7 gives the start of the year - SetTime(compileTimeAtoi(&__DATE__[7]), 1, 1, 0, 0, 0, false); } void DateTime::SetCurrentTime(std::chrono::time_point t) { @@ -41,7 +29,7 @@ void DateTime::SetCurrentTime(std::chrono::time_point= '0' && *str <= '9') { + result = result * 10 + *str - '0'; + str++; + } + return result; + } } } From b1098fd30a5d5ddd611ebdb7e3f57892f48fb31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Mart=C3=ADnez?= Date: Wed, 31 Dec 2025 18:40:34 +0100 Subject: [PATCH 3/4] Update src/utility/Math.h Co-authored-by: mark9064 <30447455+mark9064@users.noreply.github.com> --- src/utility/Math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/Math.h b/src/utility/Math.h index ac27585b66..3c65303c32 100644 --- a/src/utility/Math.h +++ b/src/utility/Math.h @@ -30,7 +30,7 @@ namespace Pinetime { return res; } - constexpr int compileTimeAtoi(const char* str) { + constexpr int CompileTimeAtoi(const char* str) { int result = 0; while (*str >= '0' && *str <= '9') { result = result * 10 + *str - '0'; From 0333bfb219646ec3b8f94b12315745fc4719b9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Mart=C3=ADnez?= Date: Wed, 31 Dec 2025 18:41:07 +0100 Subject: [PATCH 4/4] Fix function name casing in SetTime call --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index fe1ee8b134..b178934a41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -357,7 +357,7 @@ int main() { dateTimeController.SetCurrentTime(NoInit_BackUpTime); } else { // __DATE__ is a string of the format "MMM DD YYYY", so an offset of 7 gives the start of the year - dateTimeController.SetTime(Pinetime::Utility::compileTimeAtoi(&__DATE__[7]), 1, 1, 0, 0, 0); + dateTimeController.SetTime(Pinetime::Utility::CompileTimeAtoi(&__DATE__[7]), 1, 1, 0, 0, 0); // Clear Memory to known state memset(&__start_noinit_data, 0, (uintptr_t) &__stop_noinit_data - (uintptr_t) &__start_noinit_data);