We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9f2dd21 + da95415 commit 58318f9Copy full SHA for 58318f9
1 file changed
wolfcrypt/src/wc_port.c
@@ -3253,8 +3253,10 @@ time_t stm32_hal_time(time_t *t1)
3253
HAL_RTC_GetTime(&hrtc, &time, FORMAT_BIN);
3254
HAL_RTC_GetDate(&hrtc, &date, FORMAT_BIN);
3255
3256
- tm_time.tm_year = date.Year;
3257
- tm_time.tm_mon = date.Month - 1; /* gm starts at 0 */
+ /* RTC year is 0-99 and "struct tm" is 1900+, so assume after year 2000 */
+ tm_time.tm_year = date.Year + 100;
3258
+ /* RTC month is 1-12 and "struct tm" is 0-12, so subtract 1 */
3259
+ tm_time.tm_mon = date.Month - 1;
3260
tm_time.tm_mday = date.Date;
3261
tm_time.tm_hour = time.Hours;
3262
tm_time.tm_min = time.Minutes;
0 commit comments