Q:

Given the latitude and longitude, how can I tell if it's daylight?

I'm writing a Python program that needs to determine whether it's post-sunrise or not, given only the current UTC time and the target latitude and longitude. I see apps do this sort of thing all the time, but I have no idea how it's done. Any ideas?

A:

Here's someone's implementation of sunrise/sunset calculation in Python: http://michelanders.blogspot.com/2010/12/calulating-sunrise-and-sunset-in-python.html

