From 0ae9a58ade5ab0fa3bd0ad18f4cce56d6efaf021 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 2 Sep 2025 18:51:23 +0200 Subject: [PATCH] Fix date_sunrise() and date_sunset() with partial-hour UTC offset See GH-19633 Closes GH-19672 --- NEWS | 4 ++++ ext/date/php_date.c | 2 +- .../sunfuncts_partial_hour_utc_offset.phpt | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt diff --git a/NEWS b/NEWS index ccd67d5a27e..2e1ed8a2fda 100644 --- a/NEWS +++ b/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) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 910149efae6..e54b1945e1e 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -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); diff --git a/ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt b/ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt new file mode 100644 index 00000000000..279e40fa654 --- /dev/null +++ b/ext/date/tests/sunfuncts_partial_hour_utc_offset.phpt @@ -0,0 +1,18 @@ +--TEST-- +Incorrect timezone detection in date_sunrise() for partial-hour UTC offsets +--FILE-- +setTimestamp(date_sun_info($timestamp, $longitude, $latitude)['sunrise']); +echo $dt->format('H:i'), "\n"; +?> +--EXPECT-- +06:10 +06:11