Subject: | make sure loops are exited eventually |
Git pull request https://github.com/jforget/Astro-Sunrise/pull/2
We (http://geocoder.opencagedata.com/) found two edge cases were the calculation got stuck in an endless loop.
Test case sunrise(2015,11,28, 177 , -37.66667 , 0, 0, 6, 1)
It get stuck for Nov/28 and Nov/29, but it's fine for all other days. For the days I tested the loops were run 3 times so setting the maximum iterations to 100 seems reasonable.
My answer
Thank you for your bug report. Actually, I am not sure that the original writer of the module has implemented the iterative algorithm in the proper way. In other words, I think it is buggy. It does not matter much if your location is far from the qr/(ant)?arctic/ circle, but your test case shows that it must be fixed even for temperate locations. I will use your pull request for an emergency fix and later I will analyse the iterative algorithm.