formatting of sun

trying this out vs the old way
This commit is contained in:
SpudGunMan
2025-08-15 06:32:15 -07:00
parent 4fbdd42837
commit 3973406783
+7 -2
View File
@@ -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