Skip to content

Commit e015194

Browse files
committed
fix(log): fixed wrong year timestamp with LOG_TIMESTAMP_SOURCE_SYSTEM_FULL
struct tm contains the number of years since 1900, but the printing code assumed it contained actual current year. It would also print it as YYYY, while the documentation and code implies it should be YY. Closes espressif#17451
1 parent b0ec8fe commit e015194

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

components/log/src/log_timestamp_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ char* esp_log_timestamp_str(bool constrained_env, uint64_t timestamp_ms, char* b
106106
uint64_t msec = timestamp_ms % 1000;
107107
localtime_r(&sec, &timeinfo);
108108
#if CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM_FULL
109+
uint32_t year = (timeinfo.tm_year + 1900) % 100;
109110
// it takes 22 bytes to output it in the format: "YY-MM-DD HH:MM:SS.sss"
110-
buffer += esp_log_util_cvt_dec(timeinfo.tm_year, 2, buffer);
111+
buffer += esp_log_util_cvt_dec(year, 2, buffer);
111112
*buffer++ = '-';
112113
buffer += esp_log_util_cvt_dec(timeinfo.tm_mon + 1, 2, buffer);
113114
*buffer++ = '-';

0 commit comments

Comments
 (0)