From e0491fafe8ad4b82f1a4e7d66dc6d1b7705c183d Mon Sep 17 00:00:00 2001 From: Torrie Fischer Date: Fri, 13 Dec 2024 00:34:56 +0100 Subject: [PATCH] platform: esp32: fix crash when hours wrap around --- src/platform/esp32.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform/esp32.rs b/src/platform/esp32.rs index 01fb38f..f1e3e7b 100644 --- a/src/platform/esp32.rs +++ b/src/platform/esp32.rs @@ -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;