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:
4
NEWS
4
NEWS
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
18
ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt
Normal file
18
ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt
Normal 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
|
||||
Reference in New Issue
Block a user