SunRiseSet is a ruby class calculates the times of the sunrise, solar noon and sunset. It also calculates astronomical, naval and civil twilight times. Not sure of the origin of the algorithm. I have seen a fortran version http://www.srrb.noaa.gov/highlights/sunrise/program.txt a .pl www.mso.anu.edu.au/~brian/grbs/astrosubs.pl and .vb versions for spreadsheets too. All had the same comments, so are of a common origin.