Skip to content

Fix bug GH 18076 #18317

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

Open
wants to merge 3 commits into
base: PHP-8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -5418,7 +5418,7 @@ PHP_FUNCTION(date_sun_info)
array_init(return_value);

/* Get sun up/down and transit */
rs = timelib_astro_rise_set_altitude(t, longitude, latitude, -50.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit);
rs = timelib_astro_rise_set_altitude(t, longitude, latitude, -35.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit);
switch (rs) {
case -1: /* always below */
add_assoc_bool(return_value, "sunrise", 0);
Expand Down
12 changes: 12 additions & 0 deletions ext/date/tests/bug-gh18076.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
GH-18076 (Since PHP 8, date_sun_info() returns inaccurate sunrise and sunset times)
--FILE--
<?php
date_default_timezone_set("UTC");
$sun_info = date_sun_info(strtotime("2025-03-21"), 51.48, 0.0);
echo date("H:i:s\n", $sun_info['sunrise']);
echo date("H:i:s\n", $sun_info['sunset']);
?>
--EXPECT--
05:59:21
18:14:48
4 changes: 2 additions & 2 deletions ext/date/tests/date_sun_info_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ echo "Done\n";
--EXPECT--
array(9) {
["sunrise"]=>
int(1165897682)
int(1165897761)
["sunset"]=>
int(1165934239)
int(1165934160)
["transit"]=>
int(1165915961)
["civil_twilight_begin"]=>
Expand Down
4 changes: 2 additions & 2 deletions ext/date/tests/date_sun_info_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ foreach ($sun_info as $key => $elem )
echo "Done\n";
?>
--EXPECT--
2007-04-13 06:11:26 CEST sunrise
2007-04-13 20:32:56 CEST sunset
2007-04-13 06:13:31 CEST sunrise
2007-04-13 20:30:51 CEST sunset
2007-04-13 13:22:11 CEST transit
2007-04-13 05:29:22 CEST civil_twilight_begin
2007-04-13 21:15:00 CEST civil_twilight_end
Expand Down
Loading