I know that these are old yonks, but I thought I would share it since I did not find a quick solution. This uses the Sun class (see below) that I built following this link .
from Sun import Sun coords = {'longitude' : 145, 'latitude' : -38 } sun = Sun()
This seems to be accurate for a few minutes, at least where I live. For greater accuracy, the anti-aircraft parameter in the calcSunTime () method can use fine tuning. See the above link for more information.
# save this as Sun.py import math import datetime class Sun: def getSunriseTime( self, coords ): return self.calcSunTime( coords, True ) def getSunsetTime( self, coords ): return self.calcSunTime( coords, False ) def getCurrentUTC( self ): now = datetime.datetime.now() return [ now.day, now.month, now.year ] def calcSunTime( self, coords, isRiseTime, zenith = 90.8 ):
source share