From cde0e7fda1fef51574597af25d631424b8ea92fb Mon Sep 17 00:00:00 2001 From: Carlos Buenosvinos Date: Sun, 13 Apr 2025 14:19:03 +0200 Subject: [PATCH 1/3] Avoid double counting the 15 minutes radial correction of the sun --- ext/date/php_date.c | 2 +- ext/date/tests/bug-gh18076.phpt | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 ext/date/tests/bug-gh18076.phpt diff --git a/ext/date/php_date.c b/ext/date/php_date.c index c1faa842f8a1..d8a0704ca250 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -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); diff --git a/ext/date/tests/bug-gh18076.phpt b/ext/date/tests/bug-gh18076.phpt new file mode 100644 index 000000000000..641b096ccc25 --- /dev/null +++ b/ext/date/tests/bug-gh18076.phpt @@ -0,0 +1,12 @@ +--TEST-- +GH-18076 (Since PHP 8, date_sun_info() returns inaccurate sunrise and sunset times) +--FILE-- + +--EXPECT-- +05:58:41 +18:13:41 \ No newline at end of file From c4c4efa8db440354b2dacf91014da5e490afab86 Mon Sep 17 00:00:00 2001 From: Carlos Buenosvinos Date: Sun, 13 Apr 2025 14:48:31 +0200 Subject: [PATCH 2/3] Update the previous date tests and correct the output of the new test --- ext/date/tests/bug-gh18076.phpt | 4 ++-- ext/date/tests/date_sun_info_001.phpt | 4 ++-- ext/date/tests/date_sun_info_002.phpt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/date/tests/bug-gh18076.phpt b/ext/date/tests/bug-gh18076.phpt index 641b096ccc25..29baeaeefbaa 100644 --- a/ext/date/tests/bug-gh18076.phpt +++ b/ext/date/tests/bug-gh18076.phpt @@ -8,5 +8,5 @@ echo date("H:i:s\n", $sun_info['sunrise']); echo date("H:i:s\n", $sun_info['sunset']); ?> --EXPECT-- -05:58:41 -18:13:41 \ No newline at end of file +05:59:21 +18:14:48 \ No newline at end of file diff --git a/ext/date/tests/date_sun_info_001.phpt b/ext/date/tests/date_sun_info_001.phpt index 708d2550ccac..c9096af46d4b 100644 --- a/ext/date/tests/date_sun_info_001.phpt +++ b/ext/date/tests/date_sun_info_001.phpt @@ -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"]=> diff --git a/ext/date/tests/date_sun_info_002.phpt b/ext/date/tests/date_sun_info_002.phpt index 1ff58295e31e..ac319796d61c 100644 --- a/ext/date/tests/date_sun_info_002.phpt +++ b/ext/date/tests/date_sun_info_002.phpt @@ -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 From d7274630a2a2ffaedc217e079e419f7becdfdfd5 Mon Sep 17 00:00:00 2001 From: Carlos Buenosvinos Date: Wed, 16 Apr 2025 18:09:54 +0200 Subject: [PATCH 3/3] Adding EOL --- ext/date/tests/bug-gh18076.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/date/tests/bug-gh18076.phpt b/ext/date/tests/bug-gh18076.phpt index 29baeaeefbaa..2c1eaa200fad 100644 --- a/ext/date/tests/bug-gh18076.phpt +++ b/ext/date/tests/bug-gh18076.phpt @@ -9,4 +9,4 @@ echo date("H:i:s\n", $sun_info['sunset']); ?> --EXPECT-- 05:59:21 -18:14:48 \ No newline at end of file +18:14:48