Skip to content

Commit 5bb83b3

Browse files
committed
Deprecate date_sunrise() and date_sunset()
date_sunrise() and date_sunset() are deprecated in favor of date_sun_info(). Part of https://wiki.php.net/rfc/deprecations_php_8_1.
1 parent 7bbc85f commit 5bb83b3

10 files changed

+31
-4
lines changed

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ PHP 8.1 UPGRADE NOTES
332332
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate
333333
. returning a non-array from __sleep will raise a warning
334334

335+
- Date:
336+
. The date_sunrise() and date_sunset() functions have been deprecated in
337+
favor of date_sun_info().
338+
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
339+
335340
- MySQLi:
336341
. The mysqli_driver::$driver_version property has been deprecated. The driver
337342
version is meaningless as it hasn't been updated in more than a decade. Use

ext/date/php_date.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ function date_default_timezone_set(string $timezoneId): bool {}
102102

103103
function date_default_timezone_get(): string {}
104104

105+
/** @deprecated */
105106
function date_sunrise(
106107
int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
107108
?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
108109
?float $utcOffset = null): string|int|float|false {}
109110

111+
/** @deprecated */
110112
function date_sunset(
111113
int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
112114
?float $latitude = null, ?float $longitude = null, ?float $zenith = null,

ext/date/php_date_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: e8bc76a5db3a225746daffe29c0b8404cf971452 */
2+
* Stub hash: fbec11a67d5cc04667a012f25894f0d9e18833a6 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)
@@ -597,8 +597,8 @@ static const zend_function_entry ext_functions[] = {
597597
ZEND_FE(date_interval_format, arginfo_date_interval_format)
598598
ZEND_FE(date_default_timezone_set, arginfo_date_default_timezone_set)
599599
ZEND_FE(date_default_timezone_get, arginfo_date_default_timezone_get)
600-
ZEND_FE(date_sunrise, arginfo_date_sunrise)
601-
ZEND_FE(date_sunset, arginfo_date_sunset)
600+
ZEND_DEP_FE(date_sunrise, arginfo_date_sunrise)
601+
ZEND_DEP_FE(date_sunset, arginfo_date_sunset)
602602
ZEND_FE(date_sun_info, arginfo_date_sun_info)
603603
ZEND_FE_END
604604
};

ext/date/tests/date_sunrise_and_sunset_basic.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ var_dump(gettype(date_sunset(time())));
2424
?>
2525
--EXPECTF--
2626
Basic test for date_sunrise() and date_sunset()
27+
28+
Deprecated: Function date_sunrise() is deprecated in %s on line %d
2729
%s %s %d %d, sunrise time : %d:%d
30+
31+
Deprecated: Function date_sunset() is deprecated in %s on line %d
2832
%s %s %d %d, sunset time : %d:%d
33+
34+
Deprecated: Function date_sunrise() is deprecated in %s on line %d
2935
string(6) "string"
36+
37+
Deprecated: Function date_sunset() is deprecated in %s on line %d
3038
string(6) "string"

ext/date/tests/date_sunrise_and_sunset_error.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ try {
1616
}
1717

1818
?>
19-
--EXPECT--
19+
--EXPECTF--
20+
Deprecated: Function date_sunrise() is deprecated in %s on line %d
2021
date_sunrise(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE
22+
23+
Deprecated: Function date_sunset() is deprecated in %s on line %d
2124
date_sunset(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE

ext/date/tests/date_sunrise_variation7.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test date_sunrise() function : usage variation - Checking sunrise for consecutive days in specific timezone
3+
--INI--
4+
error_reporting=E_ALL&~E_DEPRECATED
35
--FILE--
46
<?php
57
echo "*** Testing date_sunrise() : usage variation ***\n";

ext/date/tests/date_sunrise_variation8.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test date_sunrise() function : usage variation - Checking with North and South poles when Sun is up and down all day
3+
--INI--
4+
error_reporting=E_ALL&~E_DEPRECATED
35
--FILE--
46
<?php
57
echo "*** Testing date_sunrise() : usage variation ***\n";

ext/date/tests/date_sunset_variation7.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test date_sunset() function : usage variation - Checking sunrise for consecutive days in specific timezone
3+
--INI--
4+
error_reporting=E_ALL&~E_DEPRECATED
35
--FILE--
46
<?php
57
echo "*** Testing date_sunset() : usage variation ***\n";

ext/date/tests/date_sunset_variation8.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test date_sunset() function : usage variation - Checking with North and South poles when Sun is up and down all day
3+
--INI--
4+
error_reporting=E_ALL&~E_DEPRECATED
35
--FILE--
46
<?php
57
echo "*** Testing date_sunset() : usage variation ***\n";

ext/date/tests/sunfuncts.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
date_sunrise() and date_sunset() functions
33
--INI--
44
precision=13
5+
error_reporting=E_ALL&~E_DEPRECATED
56
--FILE--
67
<?php
78
date_default_timezone_set('Asia/Jerusalem');

0 commit comments

Comments
 (0)