summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoeycastillo <joeycastillo@utexas.edu>2022-11-27 17:02:30 -0600
committerjoeycastillo <joeycastillo@utexas.edu>2022-11-27 17:02:30 -0600
commit444b911e9042e45e3c3ff051d0f4bd80b1a2b874 (patch)
tree628cb866ec023b86f86760bd4284420334379ea2
parent9c2c9087bfcbea1938031b8f2e64f863f7a0ed61 (diff)
downloadSensor-Watch-444b911e9042e45e3c3ff051d0f4bd80b1a2b874.tar.gz
Sensor-Watch-444b911e9042e45e3c3ff051d0f4bd80b1a2b874.tar.bz2
Sensor-Watch-444b911e9042e45e3c3ff051d0f4bd80b1a2b874.zip
fix sunrise/sunset in last 30 seconds of the hour
-rw-r--r--movement/watch_faces/complication/sunrise_sunset_face.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/movement/watch_faces/complication/sunrise_sunset_face.c b/movement/watch_faces/complication/sunrise_sunset_face.c
index 8dea812e..72424bd0 100644
--- a/movement/watch_faces/complication/sunrise_sunset_face.c
+++ b/movement/watch_faces/complication/sunrise_sunset_face.c
@@ -93,8 +93,16 @@ 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 (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);