Exposed Month and DayOfWeek texts in DateTimeController

Added static methods to return the text of a given month
or dayOfWeek.
This commit is contained in:
Tim Taenny 2021-07-09 17:32:48 +02:00
parent 06dfe14251
commit 899bee2cf5
2 changed files with 45 additions and 9 deletions

View File

@ -75,31 +75,59 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
} }
const char* DateTime::MonthShortToString() { const char* DateTime::MonthShortToString() {
return DateTime::MonthsString[(uint8_t) month]; return DateTime::MonthsString[static_cast<uint8_t>(month)];
} }
const char* DateTime::MonthShortToStringLow() { const char* DateTime::MonthShortToStringLow() {
return DateTime::MonthsStringLow[(uint8_t) month]; return DateTime::MonthsStringLow[static_cast<uint8_t>(month)];
} }
const char* DateTime::MonthsToStringLow() { const char* DateTime::MonthsToStringLow() {
return DateTime::MonthsLow[(uint8_t) month]; return DateTime::MonthsLow[static_cast<uint8_t>(month)];
} }
const char* DateTime::DayOfWeekToString() { const char* DateTime::DayOfWeekToString() {
return DateTime::DaysString[(uint8_t) dayOfWeek]; return DateTime::DaysString[static_cast<uint8_t>(dayOfWeek)];
} }
const char* DateTime::DayOfWeekShortToString() { const char* DateTime::DayOfWeekShortToString() {
return DateTime::DaysStringShort[(uint8_t) dayOfWeek]; return DateTime::DaysStringShort[static_cast<uint8_t>(dayOfWeek)];
} }
const char* DateTime::DayOfWeekToStringLow() { const char* DateTime::DayOfWeekToStringLow() {
return DateTime::DaysStringLow[(uint8_t) dayOfWeek]; return DateTime::DaysStringLow[static_cast<uint8_t>(dayOfWeek)];
} }
const char* DateTime::DayOfWeekShortToStringLow() { const char* DateTime::DayOfWeekShortToStringLow() {
return DateTime::DaysStringShortLow[(uint8_t) dayOfWeek]; return DateTime::DaysStringShortLow[static_cast<uint8_t>(dayOfWeek)];
}
const char* DateTime::MonthShortToString(Months month) {
return DateTime::MonthsString[static_cast<uint8_t>(month)];
}
const char* DateTime::MonthShortToStringLow(Months month) {
return DateTime::MonthsStringLow[static_cast<uint8_t>(month)];
}
const char* DateTime::MonthsToStringLow(Months month) {
return DateTime::MonthsLow[static_cast<uint8_t>(month)];
}
const char* DateTime::DayOfWeekToString(Days dayOfWeek) {
return DateTime::DaysString[static_cast<uint8_t>(dayOfWeek)];
}
const char* DateTime::DayOfWeekShortToString(Days dayOfWeek) {
return DateTime::DaysStringShort[static_cast<uint8_t>(dayOfWeek)];
}
const char* DateTime::DayOfWeekToStringLow(Days dayOfWeek) {
return DateTime::DaysStringLow[static_cast<uint8_t>(dayOfWeek)];
}
const char* DateTime::DayOfWeekShortToStringLow(Days dayOfWeek) {
return DateTime::DaysStringShortLow[static_cast<uint8_t>(dayOfWeek)];
} }
void DateTime::Register(Pinetime::System::SystemTask* systemTask) { void DateTime::Register(Pinetime::System::SystemTask* systemTask) {

View File

@ -66,6 +66,14 @@ namespace Pinetime {
const char* DayOfWeekToStringLow(); const char* DayOfWeekToStringLow();
const char* DayOfWeekShortToStringLow(); const char* DayOfWeekShortToStringLow();
static const char* MonthShortToString(Months month);
static const char* MonthShortToStringLow(Months month);
static const char* MonthsToStringLow(Months month);
static const char* DayOfWeekToString(Days dayOfWeek);
static const char* DayOfWeekShortToString(Days dayOfWeek);
static const char* DayOfWeekToStringLow(Days dayOfWeek);
static const char* DayOfWeekShortToStringLow(Days dayOfWeek);
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const { std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const {
return currentDateTime; return currentDateTime;
} }