platform: esp32: fix crash when hours wrap around

This commit is contained in:
Torrie Fischer 2024-12-13 00:34:56 +01:00
parent bf4ef46699
commit e0491fafe8

View File

@ -273,9 +273,9 @@ impl CircadianRhythm {
adjusted_end.hour += 24;
}
let start_time = start.hour * 60;
let end_time = end.hour * 60;
let now_time = hour * 60 + minute;
let start_time = (start.hour as u16).wrapping_mul(60);
let end_time = (end.hour as u16).wrapping_mul(60);
let now_time = (hour as u16).wrapping_mul(60).wrapping_add(minute as u16);
let duration = end_time - start_time;
let cur_duration = now_time - start_time;