Skip to content

Commit c59f786

Browse files
committed
Fix date_sunrise() with partial-hour UTC offset
See GH-19633
1 parent 6194084 commit c59f786

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/date/php_date.c

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

53305330
if (gmt_offset_is_null) {
5331-
gmt_offset = timelib_get_current_offset(t) / 3600;
5331+
gmt_offset = timelib_get_current_offset(t) / 3600.0;
53325332
}
53335333

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