Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zend-date] properly calculate sunrise, sunset and twilight times #151

Merged
merged 2 commits into from
Dec 2, 2022

Conversation

falkenhawk
Copy link
Member

@falkenhawk falkenhawk commented Nov 29, 2022

date_sunset() and date_sunrise() are deprecated in php 8.1+ - switched to recommended date_sun_info() function (which is available since php v5.1)
https://www.php.net/manual/en/function.date-sun-info.php#refsect1-function.date-sun-info-returnvalues

but that function yields slightly different results since zenith angles for sunrise/sunset/twilights are hardcoded internally
and they are different to what zf used before (see $horizonDeclination in Zend_Date::calcSun() - moved from Zend_Date::_checkLocation())

Yet ONLY NOW they are accurate! (calculations for civil / nautical / astronomical twilight were totally wrong before)

When php 8.1.0 deprecated date_sunset() and date_sunrise() functions,
switched to recommended date_sun_info() function is used instead (which is available in php since v5.1)
but that function yields slightly different results since zenith angles are internally fixed
and they are different to what zf used before. (see $horizonDeclination in Zend_Date::calcSun() - moved from Zend_Date::_checkLocation())

Yet ONLY NOW they are accurate! (calculations for civil / nautical / astronomical twilight were totally wrong before)

Still values returned by date_sun_info() are slightly different in php 8.0+, (but only for sunrise/sunset, not for twilight)
so yet another set of conditions have to be added to test suites.
@falkenhawk falkenhawk marked this pull request as ready for review November 29, 2022 16:22
Copy link
Contributor

@marcing marcing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for being so thorough with this fix.

@falkenhawk falkenhawk merged commit 6ce54ba into php81-compat Dec 2, 2022
@falkenhawk falkenhawk deleted the zend-date-sun-fixes branch December 2, 2022 17:00
falkenhawk added a commit that referenced this pull request Dec 2, 2022
* [zend-date] fix calculating sunrise, sunset and twilight times

When php 8.1.0 deprecated date_sunset() and date_sunrise() functions,
switched to recommended date_sun_info() function is used instead (which is available in php since v5.1)
but that function yields slightly different results since zenith angles are internally fixed
and they are different to what zf used before. (see $horizonDeclination in Zend_Date::calcSun() - moved from Zend_Date::_checkLocation())

Yet ONLY NOW they are accurate! (calculations for civil / nautical / astronomical twilight were totally wrong before)

Still values returned by date_sun_info() are slightly different in php 8.0+, (but only for sunrise/sunset, not for twilight)
so yet another set of conditions have to be added to test suites.
falkenhawk added a commit that referenced this pull request Dec 4, 2022
* [zend-date] fix calculating sunrise, sunset and twilight times

When php 8.1.0 deprecated date_sunset() and date_sunrise() functions,
switched to recommended date_sun_info() function is used instead (which is available in php since v5.1)
but that function yields slightly different results since zenith angles are internally fixed
and they are different to what zf used before. (see $horizonDeclination in Zend_Date::calcSun() - moved from Zend_Date::_checkLocation())

Yet ONLY NOW they are accurate! (calculations for civil / nautical / astronomical twilight were totally wrong before)

Still values returned by date_sun_info() are slightly different in php 8.0+, (but only for sunrise/sunset, not for twilight)
so yet another set of conditions have to be added to test suites.
falkenhawk added a commit that referenced this pull request Dec 6, 2022
* [zend-date] fix calculating sunrise, sunset and twilight times

When php 8.1.0 deprecated date_sunset() and date_sunrise() functions,
switched to recommended date_sun_info() function is used instead (which is available in php since v5.1)
but that function yields slightly different results since zenith angles are internally fixed
and they are different to what zf used before. (see $horizonDeclination in Zend_Date::calcSun() - moved from Zend_Date::_checkLocation())

Yet ONLY NOW they are accurate! (calculations for civil / nautical / astronomical twilight were totally wrong before)

Still values returned by date_sun_info() are slightly different in php 8.0+, (but only for sunrise/sunset, not for twilight)
so yet another set of conditions have to be added to test suites.
@falkenhawk falkenhawk mentioned this pull request Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants