Skip to content

Commit 11014b6

Browse files
committed
Fix DateTime::SetTime logging before initialized
1 parent f2814dd commit 11014b6

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/components/datetime/DateTimeController.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ DateTime::DateTime(Controllers::Settings& settingsController) : settingsControll
3131
xSemaphoreGive(mutex);
3232

3333
// __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);
34+
SetTime(compileTimeAtoi(&__DATE__[7]), 1, 1, 0, 0, 0, false);
3535
}
3636

3737
void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) {
@@ -41,7 +41,7 @@ void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock,
4141
xSemaphoreGive(mutex);
4242
}
4343

44-
void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) {
44+
void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, bool log) {
4545
std::tm tm = {
4646
/* .tm_sec = */ second,
4747
/* .tm_min = */ minute,
@@ -51,8 +51,10 @@ void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour,
5151
/* .tm_year = */ year - 1900,
5252
};
5353

54-
NRF_LOG_INFO("%d %d %d ", day, month, year);
55-
NRF_LOG_INFO("%d %d %d ", hour, minute, second);
54+
if (log) {
55+
NRF_LOG_INFO("%d %d %d ", day, month, year);
56+
NRF_LOG_INFO("%d %d %d ", hour, minute, second);
57+
}
5658

5759
tm.tm_isdst = -1; // Use DST value from local time zone
5860

src/components/datetime/DateTimeController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Pinetime {
3434
December
3535
};
3636

37-
void SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second);
37+
void SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, bool log = true);
3838

3939
/*
4040
* setter corresponding to the BLE Set Local Time characteristic.

0 commit comments

Comments
 (0)