Merge branch 'bugfix/log_sys_time_year' into 'master'

fix(log): fixed wrong year timestamp with LOG_TIMESTAMP_SOURCE_SYSTEM_FULL

Closes IDFGH-16299

See merge request espressif/esp-idf!41328
This commit is contained in:
Marius Vikhammer
2025-08-25 09:49:50 +08:00

View File

@@ -106,8 +106,9 @@ char* esp_log_timestamp_str(bool constrained_env, uint64_t timestamp_ms, char* b
uint64_t msec = timestamp_ms % 1000; uint64_t msec = timestamp_ms % 1000;
localtime_r(&sec, &timeinfo); localtime_r(&sec, &timeinfo);
#if CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM_FULL #if CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM_FULL
uint32_t year = (timeinfo.tm_year + 1900) % 100;
// it takes 22 bytes to output it in the format: "YY-MM-DD HH:MM:SS.sss" // it takes 22 bytes to output it in the format: "YY-MM-DD HH:MM:SS.sss"
buffer += esp_log_util_cvt_dec(timeinfo.tm_year, 2, buffer); buffer += esp_log_util_cvt_dec(year, 2, buffer);
*buffer++ = '-'; *buffer++ = '-';
buffer += esp_log_util_cvt_dec(timeinfo.tm_mon + 1, 2, buffer); buffer += esp_log_util_cvt_dec(timeinfo.tm_mon + 1, 2, buffer);
*buffer++ = '-'; *buffer++ = '-';