Skip to content

Commit 9c5eaac

Browse files
committed
Remove mktime() and gmmktime() $is_dst parameter
1 parent 83391b5 commit 9c5eaac

File tree

10 files changed

+24
-439
lines changed

10 files changed

+24
-439
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- Date:
4242
. Fixed day_of_week function as it could sometimes return negative values
4343
internally. (Derick)
44+
. Removed $is_dst parameter from mktime() and gmmktime(). (Nikita)
4445

4546
- DBA:
4647
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ PHP X.Y UPGRADE NOTES
6363
. Added hybrid sorting algo zend_sort for better performance.
6464
. Added stable sorting algo zend_insert_sort.
6565

66+
- Date:
67+
. Removed $is_dst parameter from mktime() and gmmktime().
68+
6669
- DBA
6770
. dba_delete() now returns false if the key was not found for the inifile
6871
handler, too.

ext/date/php_date.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,13 +1482,13 @@ PHP_FUNCTION(strtotime)
14821482
/* {{{ php_mktime - (gm)mktime helper */
14831483
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
14841484
{
1485-
zend_long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1;
1485+
zend_long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0;
14861486
timelib_time *now;
14871487
timelib_tzinfo *tzi = NULL;
14881488
zend_long ts, adjust_seconds = 0;
14891489
int error;
14901490

1491-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lllllll", &hou, &min, &sec, &mon, &day, &yea, &dst) == FAILURE) {
1491+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|llllll", &hou, &min, &sec, &mon, &day, &yea) == FAILURE) {
14921492
RETURN_FALSE;
14931493
}
14941494
/* Initialize structure with current time */
@@ -1537,27 +1537,7 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
15371537
} else {
15381538
timelib_update_ts(now, tzi);
15391539
}
1540-
/* Support for the deprecated is_dst parameter */
1541-
if (dst != -1) {
1542-
php_error_docref(NULL, E_DEPRECATED, "The is_dst parameter is deprecated");
1543-
if (gmt) {
1544-
/* GMT never uses DST */
1545-
if (dst == 1) {
1546-
adjust_seconds = -3600;
1547-
}
1548-
} else {
1549-
/* Figure out is_dst for current TS */
1550-
timelib_time_offset *tmp_offset;
1551-
tmp_offset = timelib_get_time_zone_info(now->sse, tzi);
1552-
if (dst == 1 && tmp_offset->is_dst == 0) {
1553-
adjust_seconds = -3600;
1554-
}
1555-
if (dst == 0 && tmp_offset->is_dst == 1) {
1556-
adjust_seconds = +3600;
1557-
}
1558-
timelib_time_offset_dtor(tmp_offset);
1559-
}
1560-
}
1540+
15611541
/* Clean up and return */
15621542
ts = timelib_date_to_int(now, &error);
15631543
ts += adjust_seconds;

ext/date/tests/bug27719.phpt

Lines changed: 0 additions & 67 deletions
This file was deleted.

ext/date/tests/gmmktime_error.phpt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,16 @@ $sec = 8;
1818
$mon = 8;
1919
$day = 8;
2020
$year = 2008;
21-
$extra_arg1 = 10;
22-
$extra_arg2 = 10;
21+
$extra_arg = 10;
2322

24-
var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year, $extra_arg1) );
25-
26-
var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year, $extra_arg1, $extra_arg2) );
23+
var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year, $extra_arg) );
2724
?>
2825
===DONE===
2926
--EXPECTF--
3027
*** Testing gmmktime() : error conditions ***
3128

3229
-- Testing gmmktime() function with more than expected no. of arguments --
3330

34-
Deprecated: gmmktime(): The is_dst parameter is deprecated in %s on line %d
35-
int(1218182888)
36-
37-
Warning: gmmktime() expects at most 7 parameters, 8 given in %s on line %d
31+
Warning: gmmktime() expects at most 6 parameters, 7 given in %s on line %d
3832
bool(false)
3933
===DONE===

ext/date/tests/mktime-1.phpt

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
--TEST--
22
Check for mktime with out-of-range parameters
33
--INI--
4-
error_reporting=2047
4+
error_reporting=E_ALL
55
--FILE--
66
<?php
7-
date_default_timezone_set("Europe/Amsterdam");
8-
# MacOS/X libc implementation doesn't treat out-of-range values
9-
# the same way other unices do (Bug# 10686) so some extra code
10-
# was added to datetime.c to take care of this
11-
echo date("Y-m-d", mktime( 12, 0, 0, 3, 0, 2000)) ."\n";
12-
echo date("Y-m-d", mktime( 12, 0, 0, 3, -1, 2000)) ."\n";
13-
echo date("Y-m-d", mktime( 12, 0, 0, 2, 29, 2000)) ."\n";
14-
echo date("Y-m-d", mktime( 12, 0, 0, 3, 0, 2001)) ."\n";
15-
echo date("Y-m-d", mktime( 12, 0, 0, 2, 29, 2001)) ."\n";
16-
echo date("Y-m-d", mktime( 12, 0, 0, 0, 0, 2000)) ."\n";
177

18-
putenv("TZ=Europe/London");
19-
echo date("Y-m-d H:i:s", mktime(12,0,0,3,+90,2000,-1))."\n";
20-
echo date("Y-m-d H:i:s", mktime(12,0,0,3,+90,2000,0))."\n";
21-
echo date("Y-m-d H:i:s", mktime(12,0,0,3,+90,2000,1))."\n";
22-
echo date("Y-m-d H:i:s", mktime(12,0,0,5,-90,2000,-1))."\n";
23-
echo date("Y-m-d H:i:s", mktime(12,0,0,5,-90,2000,0))."\n";
24-
echo date("Y-m-d H:i:s", mktime(12,0,0,5,-90,2000,1))."\n";
25-
echo date("Y-m-d H:i:s", mktime(12,0,0,5,-1,2000,-1))."\n";
26-
echo date("Y-m-d H:i:s", mktime(12,0,0,5,-1,2000,0))."\n";
27-
echo date("Y-m-d H:i:s", mktime(12,0,0,5,-1,2000,1))."\n";
8+
date_default_timezone_set("Europe/Amsterdam");
9+
# MacOS/X libc implementation doesn't treat out-of-range values
10+
# the same way other unices do (Bug# 10686) so some extra code
11+
# was added to datetime.c to take care of this
12+
echo date("Y-m-d", mktime( 12, 0, 0, 3, 0, 2000)) ."\n";
13+
echo date("Y-m-d", mktime( 12, 0, 0, 3, -1, 2000)) ."\n";
14+
echo date("Y-m-d", mktime( 12, 0, 0, 2, 29, 2000)) ."\n";
15+
echo date("Y-m-d", mktime( 12, 0, 0, 3, 0, 2001)) ."\n";
16+
echo date("Y-m-d", mktime( 12, 0, 0, 2, 29, 2001)) ."\n";
17+
echo date("Y-m-d", mktime( 12, 0, 0, 0, 0, 2000)) ."\n";
18+
2819
?>
2920
--EXPECT--
3021
2000-02-29
@@ -33,12 +24,3 @@ error_reporting=2047
3324
2001-02-28
3425
2001-03-01
3526
1999-11-30
36-
2000-05-29 12:00:00
37-
2000-05-29 13:00:00
38-
2000-05-29 12:00:00
39-
2000-01-31 12:00:00
40-
2000-01-31 12:00:00
41-
2000-01-31 11:00:00
42-
2000-04-29 12:00:00
43-
2000-04-29 13:00:00
44-
2000-04-29 12:00:00

ext/date/tests/mktime-2.phpt

Lines changed: 0 additions & 51 deletions
This file was deleted.

ext/date/tests/mktime_basic1.phpt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ $sec = 45;
2020
$month = 7;
2121
$day = 2;
2222
$year = 1963;
23-
$is_dst = 0;
2423

2524
var_dump( mktime($hour) );
2625
var_dump( mktime($hour, $minute) );
2726
var_dump( mktime($hour, $minute, $sec) );
2827
var_dump( mktime($hour, $minute, $sec, $month) );
2928
var_dump( mktime($hour, $minute, $sec, $month, $day) );
3029
var_dump( mktime($hour, $minute, $sec, $month, $day, $year) );
31-
var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $is_dst) );
3230

3331
?>
3432
===DONE===
@@ -40,8 +38,5 @@ int(%i)
4038
int(%i)
4139
int(%i)
4240
int(%i)
43-
44-
Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
45-
int(%i)
4641
===DONE===
4742

ext/date/tests/mktime_error.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ $sec = 45;
2424
$month = 7;
2525
$day = 2;
2626
$year = 1963;
27-
$is_dst = 0;
2827
$extra_arg = 10;
29-
var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $is_dst, $extra_arg) );
28+
var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $extra_arg) );
3029

3130
?>
3231
===DONE===
@@ -40,6 +39,6 @@ int(%d)
4039

4140
-- Testing mktime() function with more than expected no. of arguments --
4241

43-
Warning: mktime() expects at most 7 parameters, 8 given in %s on line %d
42+
Warning: mktime() expects at most 6 parameters, 7 given in %s on line %d
4443
bool(false)
4544
===DONE===

0 commit comments

Comments
 (0)