clock.py: constrain hour to 0 to 24

Use a modulo to constrain the displayed hour to 0 - 24 after applying
the UTC offset.
pull/715/head
Michael Mogenson 2023-03-14 21:18:04 -04:00
rodzic 94d5b0cd33
commit 2f26c172ed
3 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -180,7 +180,7 @@ def redraw_display_if_reqd():
year, month, day, wd, hour, minute, second, _ = rtc.datetime()
if second != last_second:
hour += utc_offset
hour = (hour + utc_offset) % 24
time_through_day = (((hour * 60) + minute) * 60) + second
percent_through_day = time_through_day / 86400
percent_to_midday = 1.0 - ((math.cos(percent_through_day * math.pi * 2) + 1) / 2)

Wyświetl plik

@ -180,7 +180,7 @@ def redraw_display_if_reqd():
year, month, day, wd, hour, minute, second, _ = rtc.datetime()
if second != last_second:
hour += utc_offset
hour = (hour + utc_offset) % 24
time_through_day = (((hour * 60) + minute) * 60) + second
percent_through_day = time_through_day / 86400
percent_to_midday = 1.0 - ((math.cos(percent_through_day * math.pi * 2) + 1) / 2)

Wyświetl plik

@ -156,7 +156,7 @@ def redraw_display_if_reqd():
year, month, day, wd, hour, minute, second, _ = rtc.datetime()
if second != last_second:
hour += utc_offset
hour = (hour + utc_offset) % 24
time_through_day = (((hour * 60) + minute) * 60) + second
percent_through_day = time_through_day / 86400
percent_to_midday = 1.0 - ((math.cos(percent_through_day * math.pi * 2) + 1) / 2)