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() {
return DateTime::MonthsString[(uint8_t) month];
return DateTime::MonthsString[static_cast<uint8_t>(month)];
}
const char* DateTime::MonthShortToStringLow() {
return DateTime::MonthsStringLow[(uint8_t) month];
return DateTime::MonthsStringLow[static_cast<uint8_t>(month)];
}
const char* DateTime::MonthsToStringLow() {
return DateTime::MonthsLow[(uint8_t) month];
return DateTime::MonthsLow[static_cast<uint8_t>(month)];
}
const char* DateTime::DayOfWeekToString() {
return DateTime::DaysString[(uint8_t) dayOfWeek];
return DateTime::DaysString[static_cast<uint8_t>(dayOfWeek)];
}
const char* DateTime::DayOfWeekShortToString() {
return DateTime::DaysStringShort[(uint8_t) dayOfWeek];
return DateTime::DaysStringShort[static_cast<uint8_t>(dayOfWeek)];
}
const char* DateTime::DayOfWeekToStringLow() {
return DateTime::DaysStringLow[(uint8_t) dayOfWeek];
return DateTime::DaysStringLow[static_cast<uint8_t>(dayOfWeek)];
}
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) {
@ -119,4 +147,4 @@ char const* DateTime::MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY",
char const* DateTime::MonthsStringLow[] = {"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
char const* DateTime::MonthsLow[] = {
"--", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
"--", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

View File

@ -66,6 +66,14 @@ namespace Pinetime {
const char* DayOfWeekToStringLow();
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 {
return currentDateTime;
}
@ -100,4 +108,4 @@ namespace Pinetime {
static char const* MonthsLow[];
};
}
}
}