jforget / Astro-Sunrise

Astro-Sunrise: computing the time of sunrise and sunset for a given location on Earth and a given date
https://metacpan.org/pod/Astro::Sunrise
Other
2 stars 3 forks source link

make sure loops are exited eventually [rt.cpan.org #109992] #4

Closed jforget closed 3 years ago

jforget commented 3 years ago

Migrated from rt.cpan.org#109992 (status was 'patched')

Requestors:

From j2n-forget@orange.fr on 2015-12-01 06:31:39 :

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.
jforget commented 3 years ago

Duplicate of .../pull/2 Fixed in Astro::Sunrise version 0.96 released on 2015-12-02.