Skip to content

Commit e843931

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix date_sunrise() and date_sunset() with partial-hour UTC offset
2 parents 8a4cbde + 73fc2db commit e843931

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
. Fixed bug GH-19637 (Incorrect Closure scope for FCC in constant
99
expression). (timwolla)
1010

11+
- Date:
12+
. Fixed date_sunrise() and date_sunset() with partial-hour UTC offset.
13+
(ilutov)
14+
1115
- EXIF:
1216
. Added support to retrieve Exif from HEIF file. (Benstone Zhang)
1317

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5493,7 +5493,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s
54935493
t->zone_type = TIMELIB_ZONETYPE_ID;
54945494

54955495
if (gmt_offset_is_null) {
5496-
gmt_offset = timelib_get_current_offset(t) / 3600;
5496+
gmt_offset = timelib_get_current_offset(t) / 3600.0;
54975497
}
54985498

54995499
timelib_unixtime2local(t, time);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Incorrect timezone detection in date_sunrise() for partial-hour UTC offsets
3+
--FILE--
4+
<?php
5+
date_default_timezone_set('Asia/Kolkata');
6+
$timestamp = mktime(0, 0, 0, 2, 9, 2025);
7+
$longitude = 22.57;
8+
$latitude = 88.36;
9+
10+
echo @date_sunrise($timestamp, SUNFUNCS_RET_STRING, $longitude, $latitude), "\n";
11+
12+
$dt = new DateTime();
13+
$dt->setTimestamp(date_sun_info($timestamp, $longitude, $latitude)['sunrise']);
14+
echo $dt->format('H:i'), "\n";
15+
?>
16+
--EXPECT--
17+
06:10
18+
06:11

0 commit comments

Comments
 (0)