From 39734067838284ae9e95e2d95f659240a7bebca5 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 15 Aug 2025 06:32:15 -0700 Subject: [PATCH] formatting of sun trying this out vs the old way --- modules/space.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/space.py b/modules/space.py index ba1d9c7..cb1c6b3 100644 --- a/modules/space.py +++ b/modules/space.py @@ -94,9 +94,14 @@ def get_sun(lat=0, lon=0): else: sun_table['rise_time'] = local_sunrise.strftime('%a %d %I:%M%p') sun_table['set_time'] = local_sunset.strftime('%a %d %I:%M%p') + + # if sunset is before sunrise, then data will be for tomorrow format sunset first and sunrise second + if local_sunset < local_sunrise: + sun_data = "SunSet: " + sun_table['set_time'] + "\nRise: " + sun_table['rise_time'] + "\nDaylight: " + else: + sun_data = "SunRise: " + sun_table['rise_time'] + "\nSet: " + sun_table['set_time'] + "\nDaylight: " - sun_data = "SunRise: " + sun_table['rise_time'] + "\nSet: " + sun_table['set_time'] + "\nDaylight: " + \ - str((local_sunset - local_sunrise).seconds // 3600) + "h " + str(((local_sunset - local_sunrise).seconds // 60) % 60) + "m" + \ + sun_data += str((local_sunset - local_sunrise).seconds // 3600) + "h " + str(((local_sunset - local_sunrise).seconds // 60) % 60) + "m" + \ "\nAzimuth: " + str('{0:.2f}'.format(sun_table['azimuth'] * 180 / ephem.pi)) + "°" + "\nAltitude: " + str('{0:.2f}'.format(sun_table['altitude'] * 180 / ephem.pi)) + "°" return sun_data