Skip to content

Commit 542284b

Browse files
committed
Remove mktime() and gmmktime() $is_dst parameter
1 parent 61dd98b commit 542284b

File tree

8 files changed

+19
-439
lines changed

8 files changed

+19
-439
lines changed

ext/date/php_date.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,13 +1499,13 @@ PHP_FUNCTION(strtotime)
14991499
/* {{{ php_mktime - (gm)mktime helper */
15001500
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
15011501
{
1502-
zend_long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1;
1502+
zend_long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0;
15031503
timelib_time *now;
15041504
timelib_tzinfo *tzi = NULL;
15051505
zend_long ts, adjust_seconds = 0;
15061506
int error;
15071507

1508-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lllllll", &hou, &min, &sec, &mon, &day, &yea, &dst) == FAILURE) {
1508+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|llllll", &hou, &min, &sec, &mon, &day, &yea) == FAILURE) {
15091509
RETURN_FALSE;
15101510
}
15111511
/* Initialize structure with current time */
@@ -1554,27 +1554,6 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
15541554
} else {
15551555
timelib_update_ts(now, tzi);
15561556
}
1557-
/* Support for the deprecated is_dst parameter */
1558-
if (dst != -1) {
1559-
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The is_dst parameter is deprecated");
1560-
if (gmt) {
1561-
/* GMT never uses DST */
1562-
if (dst == 1) {
1563-
adjust_seconds = -3600;
1564-
}
1565-
} else {
1566-
/* Figure out is_dst for current TS */
1567-
timelib_time_offset *tmp_offset;
1568-
tmp_offset = timelib_get_time_zone_info(now->sse, tzi);
1569-
if (dst == 1 && tmp_offset->is_dst == 0) {
1570-
adjust_seconds = -3600;
1571-
}
1572-
if (dst == 0 && tmp_offset->is_dst == 1) {
1573-
adjust_seconds = +3600;
1574-
}
1575-
timelib_time_offset_dtor(tmp_offset);
1576-
}
1577-
}
15781557
/* Clean up and return */
15791558
ts = timelib_date_to_int(now, &error);
15801559
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)