mirror of
https://github.com/joeycastillo/second-movement.git
synced 2025-10-29 11:38:27 +00:00
Handle hour overflow
This commit is contained in:
parent
e711fd3e60
commit
741e25db0d
@ -127,6 +127,15 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
|
||||
if (seconds < 30) scratch_time.unit.minute = floor(minutes);
|
||||
else scratch_time.unit.minute = ceil(minutes);
|
||||
|
||||
// Handle hour overflow from timezone conversion
|
||||
while (scratch_time.unit.hour >= 24) {
|
||||
scratch_time.unit.hour -= 24;
|
||||
// Increment day (this will be handled by the date arithmetic)
|
||||
uint32_t timestamp = watch_utility_date_time_to_unix_time(scratch_time, 0);
|
||||
timestamp += 86400;
|
||||
scratch_time = watch_utility_date_time_from_unix_time(timestamp, 0);
|
||||
}
|
||||
|
||||
if (scratch_time.unit.minute == 60) {
|
||||
scratch_time.unit.minute = 0;
|
||||
scratch_time.unit.hour = (scratch_time.unit.hour + 1) % 24;
|
||||
@ -157,6 +166,15 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
|
||||
if (seconds < 30) scratch_time.unit.minute = floor(minutes);
|
||||
else scratch_time.unit.minute = ceil(minutes);
|
||||
|
||||
// Handle hour overflow from timezone conversion
|
||||
while (scratch_time.unit.hour >= 24) {
|
||||
scratch_time.unit.hour -= 24;
|
||||
// Increment day (this will be handled by the date arithmetic)
|
||||
uint32_t timestamp = watch_utility_date_time_to_unix_time(scratch_time, 0);
|
||||
timestamp += 86400;
|
||||
scratch_time = watch_utility_date_time_from_unix_time(timestamp, 0);
|
||||
}
|
||||
|
||||
if (scratch_time.unit.minute == 60) {
|
||||
scratch_time.unit.minute = 0;
|
||||
scratch_time.unit.hour = (scratch_time.unit.hour + 1) % 24;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user