Python Get Sunrise and Sunset

Install the `astral` Python package.

sudo pip install astral

Display the sunrise and sunset.

import datetime
from astral import Location

# Get sunrise and sunset for Monroe, WA
l = Location()
l.latitude = 47.887059
l.longitude = -121.8792998
l.timezone = 'US/Pacific'

sunrise = l.sun()['dawn']
sunriseHour = sunrise.strftime('%H')
sunriseMinute = sunrise.strftime('%M')
print 'sunrise hour='+str(sunriseHour)
print 'sunrise minute='+str(sunriseMinute)

sunset = l.sun()['sunset']
sunsetHour = sunset.strftime('%H')
sunsetMinute = sunset.strftime('%M')
print 'sunset hour='+str(sunsetHour)
print 'sunset minute='+str(sunsetMinute)