@@ -14,24 +14,12 @@ namespace {
1414 constexpr const char * const MonthsString[] = {" --" , " JAN" , " FEB" , " MAR" , " APR" , " MAY" , " JUN" , " JUL" , " AUG" , " SEP" , " OCT" , " NOV" , " DEC" };
1515 constexpr const char * const MonthsStringLow[] =
1616 {" --" , " Jan" , " Feb" , " Mar" , " Apr" , " May" , " Jun" , " Jul" , " Aug" , " Sep" , " Oct" , " Nov" , " Dec" };
17-
18- constexpr int compileTimeAtoi (const char * str) {
19- int result = 0 ;
20- while (*str >= ' 0' && *str <= ' 9' ) {
21- result = result * 10 + *str - ' 0' ;
22- str++;
23- }
24- return result;
25- }
2617}
2718
2819DateTime::DateTime (Controllers::Settings& settingsController) : settingsController {settingsController} {
2920 mutex = xSemaphoreCreateMutex ();
3021 ASSERT (mutex != nullptr );
3122 xSemaphoreGive (mutex);
32-
33- // __DATE__ is a string of the format "MMM DD YYYY", so an offset of 7 gives the start of the year
34- SetTime (compileTimeAtoi (&__DATE__[7 ]), 1 , 1 , 0 , 0 , 0 , false );
3523}
3624
3725void DateTime::SetCurrentTime (std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) {
@@ -41,7 +29,7 @@ void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock,
4129 xSemaphoreGive (mutex);
4230}
4331
44- void DateTime::SetTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, bool log ) {
32+ void DateTime::SetTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) {
4533 std::tm tm = {
4634 /* .tm_sec = */ second,
4735 /* .tm_min = */ minute,
@@ -51,10 +39,8 @@ void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour,
5139 /* .tm_year = */ year - 1900 ,
5240 };
5341
54- if (log) {
55- NRF_LOG_INFO (" %d %d %d " , day, month, year);
56- NRF_LOG_INFO (" %d %d %d " , hour, minute, second);
57- }
42+ NRF_LOG_INFO (" %d %d %d " , day, month, year);
43+ NRF_LOG_INFO (" %d %d %d " , hour, minute, second);
5844
5945 tm.tm_isdst = -1 ; // Use DST value from local time zone
6046
0 commit comments