Skip to content

Commit adcd292

Browse files
committed
Fix mktime test DST error
Initialize all values of timeinfo in make_time_info. This prevents the field 'tm_isdst' from getting inadvertently set to 1 causing time to be off by 1 hour.
1 parent d6af53c commit adcd292

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

TESTS/mbed_hal/rtc_time/main.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,17 @@ void test_is_leap_year() {
6565
}
6666

6767
struct tm make_time_info(int year, int month, int day, int hours, int minutes, int seconds) {
68-
struct tm timeinfo;
69-
timeinfo.tm_year = year;
70-
timeinfo.tm_mon = month;
71-
timeinfo.tm_mday = day;
72-
timeinfo.tm_hour = hours;
73-
timeinfo.tm_min = minutes;
74-
timeinfo.tm_sec = seconds;
68+
struct tm timeinfo = {
69+
seconds, // tm_sec
70+
minutes, // tm_min
71+
hours, // tm_hour
72+
day, // tm_mday
73+
month, // tm_mon
74+
year, // tm_year
75+
0, // tm_wday
76+
0, // tm_yday
77+
0, // tm_isdst
78+
};
7579
return timeinfo;
7680
}
7781

0 commit comments

Comments
 (0)