1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix date_sunrise() and date_sunset() with partial-hour UTC offset

See GH-19633
Closes GH-19672
This commit is contained in:
Ilija Tovilo
2025-09-02 18:51:23 +02:00
parent 6194084837
commit 0ae9a58ade
3 changed files with 23 additions and 1 deletions

4
NEWS
View File

@@ -10,6 +10,10 @@ PHP NEWS
. Fixed bug GH-19544 (GC treats ZEND_WEAKREF_TAG_MAP references as WeakMap
references). (Arnaud, timwolla)
- Date:
. Fixed date_sunrise() and date_sunset() with partial-hour UTC offset.
(ilutov)
- OpenSSL:
. Fixed bug GH-19245 (Success error message on TLS stream accept failure).
(Jakub Zelenka)

View File

@@ -5328,7 +5328,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s
t->zone_type = TIMELIB_ZONETYPE_ID;
if (gmt_offset_is_null) {
gmt_offset = timelib_get_current_offset(t) / 3600;
gmt_offset = timelib_get_current_offset(t) / 3600.0;
}
timelib_unixtime2local(t, time);

View File

@@ -0,0 +1,18 @@
--TEST--
Incorrect timezone detection in date_sunrise() for partial-hour UTC offsets
--FILE--
<?php
date_default_timezone_set('Asia/Kolkata');
$timestamp = mktime(0, 0, 0, 2, 9, 2025);
$longitude = 22.57;
$latitude = 88.36;
echo @date_sunrise($timestamp, SUNFUNCS_RET_STRING, $longitude, $latitude), "\n";
$dt = new DateTime();
$dt->setTimestamp(date_sun_info($timestamp, $longitude, $latitude)['sunrise']);
echo $dt->format('H:i'), "\n";
?>
--EXPECT--
06:10
06:11