From 423c5ec70e8ba90dd1b899ce2b5433fcf7a9c0fc Mon Sep 17 00:00:00 2001 From: joeycastillo Date: Mon, 28 Nov 2022 00:40:08 -0600 Subject: address sunrise/set rounding in last 30 seconds of hour (fixes #146) --- .../watch_faces/complication/sunrise_sunset_face.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/movement/watch_faces/complication/sunrise_sunset_face.c b/movement/watch_faces/complication/sunrise_sunset_face.c index 72424bd0..8bc18ddd 100644 --- a/movement/watch_faces/complication/sunrise_sunset_face.c +++ b/movement/watch_faces/complication/sunrise_sunset_face.c @@ -93,15 +93,12 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s minutes = 60.0 * fmod(rise, 1); seconds = 60.0 * fmod(minutes, 1); scratch_time.unit.hour = floor(rise); - if (seconds < 30) { - scratch_time.unit.minute = floor(minutes); - } - else { - scratch_time.unit.minute = ceil(minutes); - if (scratch_time.unit.minute == 60) { - scratch_time.unit.minute = 0; - scratch_time.unit.hour = (scratch_time.unit.hour + 1) % 24; - } + if (seconds < 30) scratch_time.unit.minute = floor(minutes); + else scratch_time.unit.minute = ceil(minutes); + + if (scratch_time.unit.minute == 60) { + scratch_time.unit.minute = 0; + scratch_time.unit.hour = (scratch_time.unit.hour + 1) % 24; } if (date_time.reg < scratch_time.reg) _sunrise_sunset_set_expiration(state, scratch_time); @@ -126,6 +123,11 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s if (seconds < 30) scratch_time.unit.minute = floor(minutes); else scratch_time.unit.minute = ceil(minutes); + if (scratch_time.unit.minute == 60) { + scratch_time.unit.minute = 0; + scratch_time.unit.hour = (scratch_time.unit.hour + 1) % 24; + } + if (date_time.reg < scratch_time.reg) _sunrise_sunset_set_expiration(state, scratch_time); if (date_time.reg < scratch_time.reg || show_next_match) { -- cgit v1.2.3