局部变量tm_new未初始化,该结构体变量中的tm_isdst值为栈中残留值,不确定,该值会影响是否使用夏令时,最终表现概率性使用夏令时,出现相差1小时的问题。将其初始化为0,默认不使用夏令时

This commit is contained in:
ifreecoding 2020-05-21 17:13:36 +08:00
parent 19c01e9d5e
commit 76cd1608a7
1 changed files with 1 additions and 1 deletions

View File

@ -37,7 +37,7 @@ static time_t get_rtc_timestamp(void)
{
RTC_TimeTypeDef RTC_TimeStruct = {0};
RTC_DateTypeDef RTC_DateStruct = {0};
struct tm tm_new;
struct tm tm_new = {0};
HAL_RTC_GetTime(&RTC_Handler, &RTC_TimeStruct, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN);