From 5d971690cb7fcf51e0215a9eda16136607cf1851 Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Mon, 12 Feb 2024 15:59:40 -0500 Subject: [PATCH] DateTimeController: Make DayOfWeekShortToStringLow static This allows it to be used outside of the current datetime context and makes it consistent with the MonthShortToStringLow function. --- src/components/datetime/DateTimeController.cpp | 4 ++-- src/components/datetime/DateTimeController.h | 2 +- src/displayapp/screens/WatchFaceInfineat.cpp | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index 8d4a834e..f0ccb5e5 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -115,8 +115,8 @@ const char* DateTime::MonthShortToStringLow(Months month) { return MonthsStringLow[static_cast(month)]; } -const char* DateTime::DayOfWeekShortToStringLow() const { - return DaysStringShortLow[static_cast(DayOfWeek())]; +const char* DateTime::DayOfWeekShortToStringLow(Days day) { + return DaysStringShortLow[static_cast(day)]; } void DateTime::Register(Pinetime::System::SystemTask* systemTask) { diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index 0bf6ac2a..f719df7d 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -122,7 +122,7 @@ namespace Pinetime { const char* MonthShortToString() const; const char* DayOfWeekShortToString() const; static const char* MonthShortToStringLow(Months month); - const char* DayOfWeekShortToStringLow() const; + static const char* DayOfWeekShortToStringLow(Days day); std::chrono::time_point CurrentDateTime() const { return currentDateTime; diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index 3308303d..c643f3bd 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -426,7 +426,8 @@ void WatchFaceInfineat::Refresh() { currentDate = std::chrono::time_point_cast(currentDateTime.Get()); if (currentDate.IsUpdated()) { uint8_t day = dateTimeController.Day(); - lv_label_set_text_fmt(labelDate, "%s %02d", dateTimeController.DayOfWeekShortToStringLow(), day); + Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); + lv_label_set_text_fmt(labelDate, "%s %02d", dateTimeController.DayOfWeekShortToStringLow(dayOfWeek), day); lv_obj_realign(labelDate); } }