Skip to content

Commit cde0e7f

Browse files
Avoid double counting the 15 minutes radial correction of the sun
1 parent 8849a53 commit cde0e7f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5418,7 +5418,7 @@ PHP_FUNCTION(date_sun_info)
54185418
array_init(return_value);
54195419

54205420
/* Get sun up/down and transit */
5421-
rs = timelib_astro_rise_set_altitude(t, longitude, latitude, -50.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit);
5421+
rs = timelib_astro_rise_set_altitude(t, longitude, latitude, -35.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit);
54225422
switch (rs) {
54235423
case -1: /* always below */
54245424
add_assoc_bool(return_value, "sunrise", 0);

ext/date/tests/bug-gh18076.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-18076 (Since PHP 8, date_sun_info() returns inaccurate sunrise and sunset times)
3+
--FILE--
4+
<?php
5+
date_default_timezone_set("UTC");
6+
$sun_info = date_sun_info(strtotime("2025-03-21"), 51.48, 0.0);
7+
echo date("H:i:s\n", $sun_info['sunrise']);
8+
echo date("H:i:s\n", $sun_info['sunset']);
9+
?>
10+
--EXPECT--
11+
05:58:41
12+
18:13:41

0 commit comments

Comments
 (0)