Skip to content

Commit 0ae9a58

Browse files
committed
Fix date_sunrise() and date_sunset() with partial-hour UTC offset
See phpGH-19633 Closes phpGH-19672
1 parent 6194084 commit 0ae9a58

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
- OpenSSL:
1418
. Fixed bug GH-19245 (Success error message on TLS stream accept failure).
1519
(Jakub Zelenka)

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)