Skip to content

Commit d08f17f

Browse files
committed
Deprecate DATE_RET_* constants (related to date_sunrise/date_sunset)
Related: 5bb83b3 `date_sunrise` and `date_sunset` functions are deprecated in PHP 8.1, along with the ini settings. Both `date_sunrise` and `date_sunset` functions accept a parameter to specify the format of the returned time. They accept one of the three following constants: - `SUNFUNCS_RET_STRING` - `SUNFUNCS_RET_DOUBLE` - `SUNFUNCS_RET_TIMESTAMP` These constants are only used with `date_sunrise` and `date_sunset` functions, and are not used anywhere. This deprecates the three constants.
1 parent 172f84b commit d08f17f

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

UPGRADING

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@ PHP 8.1 UPGRADE NOTES
361361

362362
- Date:
363363
. The date_sunrise() and date_sunset() functions have been deprecated in
364-
favor of date_sun_info().
364+
favor of date_sun_info(). Their related ini settings
365+
date.default_latitude, date.default_longitude and date.sunset_zenith,
366+
along with constants SUNFUNCS_RET_STRING, SUNFUNCS_RET_DOUBLE, and
367+
SUNFUNCS_RET_TIMESTAMP are also deprecated.
365368
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
366369
. The strftime() and gmstrftime() functions have been deprecated in favor of
367370
date()/DateTime::format() (for locale-independent formatting) or

ext/date/php_date.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ PHP_MINIT_FUNCTION(date)
413413
REGISTER_STRING_CONSTANT("DATE_RSS", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
414414
REGISTER_STRING_CONSTANT("DATE_W3C", DATE_FORMAT_RFC3339, CONST_CS | CONST_PERSISTENT);
415415

416-
REGISTER_LONG_CONSTANT("SUNFUNCS_RET_TIMESTAMP", SUNFUNCS_RET_TIMESTAMP, CONST_CS | CONST_PERSISTENT);
417-
REGISTER_LONG_CONSTANT("SUNFUNCS_RET_STRING", SUNFUNCS_RET_STRING, CONST_CS | CONST_PERSISTENT);
418-
REGISTER_LONG_CONSTANT("SUNFUNCS_RET_DOUBLE", SUNFUNCS_RET_DOUBLE, CONST_CS | CONST_PERSISTENT);
416+
REGISTER_LONG_CONSTANT("SUNFUNCS_RET_TIMESTAMP", SUNFUNCS_RET_TIMESTAMP, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);
417+
REGISTER_LONG_CONSTANT("SUNFUNCS_RET_STRING", SUNFUNCS_RET_STRING, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);
418+
REGISTER_LONG_CONSTANT("SUNFUNCS_RET_DOUBLE", SUNFUNCS_RET_DOUBLE, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);
419419

420420
php_date_global_timezone_db = NULL;
421421
php_date_global_timezone_db_enabled = 0;

ext/date/tests/date_sunrise_and_sunset_basic.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ var_dump(gettype(date_sunset(time())));
2525
--EXPECTF--
2626
Basic test for date_sunrise() and date_sunset()
2727

28+
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
2829
Deprecated: Function date_sunrise() is deprecated in %s on line %d
2930
%s %s %d %d, sunrise time : %d:%d
3031

32+
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
3133
Deprecated: Function date_sunset() is deprecated in %s on line %d
3234
%s %s %d %d, sunset time : %d:%d
3335

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
SUNFUNCS_RET_STRING, SUNFUNCS_RET_DOUBLE, and SUNFUNCS_RET_TIMESTAMP constants are deprecated
3+
--FILE--
4+
<?php
5+
6+
var_dump(SUNFUNCS_RET_STRING);
7+
var_dump(SUNFUNCS_RET_DOUBLE);
8+
var_dump(SUNFUNCS_RET_TIMESTAMP);
9+
10+
?>
11+
--EXPECTF--
12+
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
13+
int(1)
14+
15+
Deprecated: Constant SUNFUNCS_RET_DOUBLE is deprecated in %s on line %d
16+
int(2)
17+
18+
Deprecated: Constant SUNFUNCS_RET_TIMESTAMP is deprecated in %s on line %d
19+
int(0)

0 commit comments

Comments
 (0)