Skip to content

Commit 73fc2db

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix date_sunrise() and date_sunset() with partial-hour UTC offset
2 parents d59ae93 + 0ae9a58 commit 73fc2db

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
@@ -10,6 +10,10 @@ PHP NEWS
1010
. Fixed bug GH-19544 (GC treats ZEND_WEAKREF_TAG_MAP references as WeakMap
1111
references). (Arnaud, timwolla)
1212

13+
- Date:
14+
. Fixed date_sunrise() and date_sunset() with partial-hour UTC offset.
15+
(ilutov)
16+
1317
- Opcache:
1418
. Fixed bug GH-19493 (JIT variable not stored before YIELD). (Arnaud)
1519

ext/date/php_date.c

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

55575557
if (gmt_offset_is_null) {
5558-
gmt_offset = timelib_get_current_offset(t) / 3600;
5558+
gmt_offset = timelib_get_current_offset(t) / 3600.0;
55595559
}
55605560

55615561
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)