Asr calculation uses server's system time, drifts over course of day
cpfair opened this issue · comments
As-salaamu alaykum,
I noticed that the Asr calculation uses the server's local time for the fractional component of the Julian day (date('i') + date('s')
):
prayer-times/src/PrayerTimes/PrayerTimes.php
Lines 529 to 550 in 5844f0d
This means that the server can return different Asr times for the same API call, depending on when in the day the call is made (relative to the system time of the server).
For example, this randomly generated API call for a specific date and lat/lng. When I made the API call a few days ago at 17:33, the Asr time was 13:57. When I make the same call now (at 08:15), the Asr time is 13:59. All other times are identical, as one would hope.
I don't think the Asr time should change based on when the API call is made relative to the server's clock. I think the original PrayTimes calculation is correct here.
3laykum salaam @cpfair. Thank you, this is a good catch and clearly a bug as the date that should be used here is $this->date
instead of the date()
function.
This is the result of fast coding 😄. I remember this change was made because the native php julian date function did not take fractions into account, and this produced inaccurate results. There's a long discussion on the Discord server somewhere about this, but I'm guessing at that point we made the change, tested what was then 'today' and moved on.
I'll try and patch this over the next couple of days.