Is there a simple method of determining, given a UTC date/time, whether it is day or night at a given lat/long coordinate?
I am currently using a formula based on a Sunrise/Sunset Algorithm from the US Naval Observatory, but unfortunately I am having trouble applying to arrive at a simple night/day indicator.
Should I build upon this formula or is there some more efficient way of doing this that I am missing?
Disclaimer: I am a programmer, not an astronomer, so I find the formulas for astronomical calculations a bit confusing.
Extra stuff: Ideally I would like to artificially shorten the period of "night" by two hours, for the purposes of eliminating some false positives from sensor data that occurs during twilight/dawn. In other words, if sunset occurs at 7 pm at a given location, I would like the option of padding the value by 60 minutes such that the output remains "day" until 8 pm for that location. (And apply the same padding prior to sunrise.)
I wound up calculating the sun's altitude for the location using a UTC timestamp and the location's lat/long coordinates. Using figures for various twilight amounts (6, 12, 18 or degrees below horizon) I am able to automatically select the portion of "night" that is sufficiently dark. (e.g. 6 degrees below horizon is not as dark as 12 degrees.) This approach was much easier than attempting to determine sunrise and sunset times for the locale's time zone (and all of the associated time zone headaches).