From 96217e0add56990d1bfb11fd7545ec7f75a867ee Mon Sep 17 00:00:00 2001 From: Adrian Baumgart Date: Sat, 15 Jun 2024 17:54:57 +0200 Subject: [PATCH] fixed 24-hour format not working for sunrise/sunset (#137) --- src/frontendCardDayNight.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/frontendCardDayNight.py b/src/frontendCardDayNight.py index f4faf50..129fd61 100644 --- a/src/frontendCardDayNight.py +++ b/src/frontendCardDayNight.py @@ -41,8 +41,15 @@ def get_sunset_sunrise_degree(self): sunset_ts = daily_data.sunset.get("data")[i] break - sunrise = datetime.fromtimestamp(sunrise_ts - time_diff).strftime("%I:%M %p") - sunset = datetime.fromtimestamp(sunset_ts - time_diff).strftime("%I:%M %p") + sunrise_dt = datetime.fromtimestamp(sunrise_ts - time_diff) + sunset_dt = datetime.fromtimestamp(sunset_ts - time_diff) + + sunrise = sunrise_dt.strftime("%I:%M %p") + sunset = sunset_dt.strftime("%I:%M %p") + + if settings.is_using_24h_clock: + sunrise = sunrise_dt.strftime("%H:%M") + sunset = sunset_dt.strftime("%H:%M") # Caclulate Sun rotation degree = 0