You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Since PHP 8, the date_sun_info() function returns inaccurate sunrise and sunset times, but other calculated times are correct #18076
I think the problem is in the call function timelib_astro_rise_set_altitude() in /ext/date/php_date.c
Back in PHP 7.4.33 it was called like this
timelib_astro_rise_set_altitude(t, longitude, latitude, -35.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit); https://github.com/php/php-src/blob/PHP-7.4.33/ext/date/php_date.c#L5146
The fourth parameter, -35.0/60, is the refraction value in degrees.
In the timelib_astro_rise_set_altitude() function then subtracts the calculated apparent radius of the Sun (which is approximately 15.0/60) https://github.com/php/php-src/blob/PHP-7.4.33/ext/date/lib/astro.c#L260 (the variable upper_limb is always 1)
The result is the correct topocentric altitude (-50/60 degrees) needed to calculate the sunrise and sunset times.
However, since PHP 8, it is called timelib_astro_rise_set_altitude(t, longitude, latitude, -50.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit); https://github.com/php/php-src/blob/PHP-8.0/ext/date/php_date.c#L4663
The fourth parameter, -50.0/60, is refraction and apparent radius together. But in the function itself, the subtraction of the calculated apparent radius of the Sun is still done.
The resulting topocentric altitude (-65/60 degrees) is wrong and consequently so are the calculated sunrise and sunset times. The other calculated times (transit and *twilight*) are correct.
This got changed by @cmb69 in 7556600 per an incorrect statement in https://bugs.php.net/bug.php?id=65547, where the "apparent radius of the Sun (which is approximately 15.0/60)" is ignored altogether.
If I understand the situation rightly, the 50/60 given in the NAO-published algorithm is a 15-minute correction for the angular radius of the sun plus a 35-minute correction for atmospheric refraction.
But as coded the radial correction is already accounted for elsewhere and so shouldn't be included here as well, which means the figure should be 35/60.
Activity
derickr commentedon Mar 28, 2025
This got changed by @cmb69 in 7556600 per an incorrect statement in https://bugs.php.net/bug.php?id=65547, where the "apparent radius of the Sun (which is approximately 15.0/60)" is ignored altogether.
I think that change should be reverted.
carlosbuenosvinos commentedon Apr 12, 2025
I have run some tests:
https://3v4l.org/01QlB#v8.4.6
https://3v4l.org/01QlB#v8.0.0
https://3v4l.org/01QlB#v7.4.33
@derickr, double checking, to fix it I understand that I should create the test, PR, and wait for approval, correct?
MorganLOCode commentedon Apr 13, 2025
If I understand the situation rightly, the 50/60 given in the NAO-published algorithm is a 15-minute correction for the angular radius of the sun plus a 35-minute correction for atmospheric refraction.
But as coded the radial correction is already accounted for elsewhere and so shouldn't be included here as well, which means the figure should be 35/60.
Have I got that right?
JiriJozif commentedon Apr 13, 2025
Yes, that's the correct description.
carlosbuenosvinos commentedon Apr 13, 2025
PR created: #18317
Fix GH-18076: date_sun_info() function returns inaccurate sunrise and…