- Date:
. Fixed day_of_week function as it could sometimes return negative values
internally. (Derick)
+ . Removed $is_dst parameter from mktime() and gmmktime(). (Nikita)
- DBA:
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)
. Added hybrid sorting algo zend_sort for better performance.
. Added stable sorting algo zend_insert_sort.
+- Date:
+ . Removed $is_dst parameter from mktime() and gmmktime().
+
- DBA
. dba_delete() now returns false if the key was not found for the inifile
handler, too.
/* {{{ php_mktime - (gm)mktime helper */
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
{
- zend_long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1;
+ zend_long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0;
timelib_time *now;
timelib_tzinfo *tzi = NULL;
zend_long ts, adjust_seconds = 0;
int error;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lllllll", &hou, &min, &sec, &mon, &day, &yea, &dst) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|llllll", &hou, &min, &sec, &mon, &day, &yea) == FAILURE) {
RETURN_FALSE;
}
/* Initialize structure with current time */
} else {
timelib_update_ts(now, tzi);
}
- /* Support for the deprecated is_dst parameter */
- if (dst != -1) {
- php_error_docref(NULL, E_DEPRECATED, "The is_dst parameter is deprecated");
- if (gmt) {
- /* GMT never uses DST */
- if (dst == 1) {
- adjust_seconds = -3600;
- }
- } else {
- /* Figure out is_dst for current TS */
- timelib_time_offset *tmp_offset;
- tmp_offset = timelib_get_time_zone_info(now->sse, tzi);
- if (dst == 1 && tmp_offset->is_dst == 0) {
- adjust_seconds = -3600;
- }
- if (dst == 0 && tmp_offset->is_dst == 1) {
- adjust_seconds = +3600;
- }
- timelib_time_offset_dtor(tmp_offset);
- }
- }
+
/* Clean up and return */
ts = timelib_date_to_int(now, &error);
ts += adjust_seconds;
+++ /dev/null
---TEST--
-Bug #27719 (mktime returns incorrect timestamp for dst days)
---INI--
-date.timezone=EST
-error_reporting=2047
---FILE--
-<?php /* $Id$ */
- $a = mktime(0, 0, 0, 4, 4, 2004, 0);
- $b = mktime(0, 0, 0, 4, 4, 2004, 1);
- $c = mktime(0, 0, 0, 4, 4, 2004, -1);
- echo "$a ".date("m/d/y h:i:s\n",$a);
- echo "$b ".date("m/d/y h:i:s\n",$b);
- echo "$c ".date("m/d/y h:i:s\n",$c);
- echo "\n";
- date_default_timezone_set('EST5EDT'); // DST not in effect
- $a = mktime(0, 0, 0, 2, 4, 2004, 0);
- $b = mktime(0, 0, 0, 2, 4, 2004, 1);
- $c = mktime(0, 0, 0, 2, 4, 2004, -1);
- echo "$a ".date("m/d/y h:i:s\n",$a);
- echo "$b ".date("m/d/y h:i:s\n",$b);
- echo "$c ".date("m/d/y h:i:s\n",$c);
- echo "\n";
- date_default_timezone_set('EST5EDT');
- $a = mktime(0, 0, 0, 4, 4, 2004, 0);
- $b = mktime(0, 0, 0, 4, 4, 2004, 1);
- $c = mktime(0, 0, 0, 4, 4, 2004, -1);
- echo "$a ".date("m/d/y h:i:s\n",$a);
- echo "$b ".date("m/d/y h:i:s\n",$b);
- echo "$c ".date("m/d/y h:i:s\n",$c);
- echo "\n";
- date_default_timezone_set('EST5EDT');
- $a = mktime(3, 0, 0, 4, 4, 2004, 0);
- $b = mktime(3, 0, 0, 4, 4, 2004, 1);
- $c = mktime(3, 0, 0, 4, 4, 2004, -1);
- echo "$a ".date("m/d/y h:i:s\n",$a);
- echo "$b ".date("m/d/y h:i:s\n",$b);
- echo "$c ".date("m/d/y h:i:s\n",$c);
- echo "\n";
- date_default_timezone_set('EST5EDT');
- $a = mktime(0, 0, 0, 6, 4, 2004, 0);
- $b = mktime(0, 0, 0, 6, 4, 2004, 1);
- $c = mktime(0, 0, 0, 6, 4, 2004, -1);
- echo "$a ".date("m/d/y h:i:s\n",$a);
- echo "$b ".date("m/d/y h:i:s\n",$b);
- echo "$c ".date("m/d/y h:i:s\n",$c);
- echo "\n";
-?>
---EXPECTF--
-1081054800 04/04/04 12:00:00
-%s
-1081054800 04/04/04 12:00:00
-
-1075870800 02/04/04 12:00:00
-1075867200 02/03/04 11:00:00
-1075870800 02/04/04 12:00:00
-
-1081054800 04/04/04 12:00:00
-1081051200 04/03/04 11:00:00
-1081054800 04/04/04 12:00:00
-
-1081065600 04/04/04 04:00:00
-1081062000 04/04/04 03:00:00
-1081062000 04/04/04 03:00:00
-
-1086325200 06/04/04 01:00:00
-1086321600 06/04/04 12:00:00
-1086321600 06/04/04 12:00:00
$mon = 8;
$day = 8;
$year = 2008;
-$extra_arg1 = 10;
-$extra_arg2 = 10;
+$extra_arg = 10;
-var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year, $extra_arg1) );
-
-var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year, $extra_arg1, $extra_arg2) );
+var_dump( gmmktime($hour, $min, $sec, $mon, $day, $year, $extra_arg) );
?>
===DONE===
--EXPECTF--
-- Testing gmmktime() function with more than expected no. of arguments --
-Deprecated: gmmktime(): The is_dst parameter is deprecated in %s on line %d
-int(1218182888)
-
-Warning: gmmktime() expects at most 7 parameters, 8 given in %s on line %d
+Warning: gmmktime() expects at most 6 parameters, 7 given in %s on line %d
bool(false)
===DONE===
--TEST--
Check for mktime with out-of-range parameters
--INI--
-error_reporting=2047
+error_reporting=E_ALL
--FILE--
<?php
- date_default_timezone_set("Europe/Amsterdam");
- # MacOS/X libc implementation doesn't treat out-of-range values
- # the same way other unices do (Bug# 10686) so some extra code
- # was added to datetime.c to take care of this
- echo date("Y-m-d", mktime( 12, 0, 0, 3, 0, 2000)) ."\n";
- echo date("Y-m-d", mktime( 12, 0, 0, 3, -1, 2000)) ."\n";
- echo date("Y-m-d", mktime( 12, 0, 0, 2, 29, 2000)) ."\n";
- echo date("Y-m-d", mktime( 12, 0, 0, 3, 0, 2001)) ."\n";
- echo date("Y-m-d", mktime( 12, 0, 0, 2, 29, 2001)) ."\n";
- echo date("Y-m-d", mktime( 12, 0, 0, 0, 0, 2000)) ."\n";
- putenv("TZ=Europe/London");
- echo date("Y-m-d H:i:s", mktime(12,0,0,3,+90,2000,-1))."\n";
- echo date("Y-m-d H:i:s", mktime(12,0,0,3,+90,2000,0))."\n";
- echo date("Y-m-d H:i:s", mktime(12,0,0,3,+90,2000,1))."\n";
- echo date("Y-m-d H:i:s", mktime(12,0,0,5,-90,2000,-1))."\n";
- echo date("Y-m-d H:i:s", mktime(12,0,0,5,-90,2000,0))."\n";
- echo date("Y-m-d H:i:s", mktime(12,0,0,5,-90,2000,1))."\n";
- echo date("Y-m-d H:i:s", mktime(12,0,0,5,-1,2000,-1))."\n";
- echo date("Y-m-d H:i:s", mktime(12,0,0,5,-1,2000,0))."\n";
- echo date("Y-m-d H:i:s", mktime(12,0,0,5,-1,2000,1))."\n";
+date_default_timezone_set("Europe/Amsterdam");
+# MacOS/X libc implementation doesn't treat out-of-range values
+# the same way other unices do (Bug# 10686) so some extra code
+# was added to datetime.c to take care of this
+echo date("Y-m-d", mktime( 12, 0, 0, 3, 0, 2000)) ."\n";
+echo date("Y-m-d", mktime( 12, 0, 0, 3, -1, 2000)) ."\n";
+echo date("Y-m-d", mktime( 12, 0, 0, 2, 29, 2000)) ."\n";
+echo date("Y-m-d", mktime( 12, 0, 0, 3, 0, 2001)) ."\n";
+echo date("Y-m-d", mktime( 12, 0, 0, 2, 29, 2001)) ."\n";
+echo date("Y-m-d", mktime( 12, 0, 0, 0, 0, 2000)) ."\n";
+
?>
--EXPECT--
2000-02-29
2001-02-28
2001-03-01
1999-11-30
-2000-05-29 12:00:00
-2000-05-29 13:00:00
-2000-05-29 12:00:00
-2000-01-31 12:00:00
-2000-01-31 12:00:00
-2000-01-31 11:00:00
-2000-04-29 12:00:00
-2000-04-29 13:00:00
-2000-04-29 12:00:00
+++ /dev/null
---TEST--
-mktime() [2]
---INI--
-error_reporting=2047
---FILE--
-<?php
-$timezones = array(
- 'UTC',
- 'Europe/London'
-);
-
-foreach($timezones as $timezone)
-{
- date_default_timezone_set($timezone);
-
- /* status of daylight saving time unknown */
- var_dump(mktime(0, 0, 0, 1, 1, 2002));
- /* status of daylight saving time unknown */
- var_dump(mktime(0, 0, 0, 1, 1, 2002, -1));
- /* daylight saving time is not in effect */
- var_dump(mktime(0, 0, 0, 1, 1, 2002, 0));
- /* daylight saving time is in effect */
- var_dump(mktime(0, 0, 0, 1, 1, 2002, 1));
-
- /* status of daylight saving time unknown */
- var_dump(mktime(0, 0, 0, 7, 1, 2002));
- /* status of daylight saving time unknown */
- var_dump(mktime(0, 0, 0, 7, 1, 2002, -1));
- /* daylight saving time is not in effect */
- var_dump(mktime(0, 0, 0, 7, 1, 2002, 0));
- /* daylight saving time is in effect */
- var_dump(mktime(0, 0, 0, 7, 1, 2002, 1));
-}
-?>
---EXPECTF--
-int(1009843200)
-int(1009843200)
-int(1009843200)
-int(%s)
-int(1025481600)
-int(1025481600)
-int(1025481600)
-int(%s)
-int(1009843200)
-int(1009843200)
-int(1009843200)
-int(1009839600)
-int(1025478000)
-int(1025478000)
-int(1025481600)
-int(1025478000)
$month = 7;
$day = 2;
$year = 1963;
-$is_dst = 0;
var_dump( mktime($hour) );
var_dump( mktime($hour, $minute) );
var_dump( mktime($hour, $minute, $sec, $month) );
var_dump( mktime($hour, $minute, $sec, $month, $day) );
var_dump( mktime($hour, $minute, $sec, $month, $day, $year) );
-var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $is_dst) );
?>
===DONE===
int(%i)
int(%i)
int(%i)
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
===DONE===
$month = 7;
$day = 2;
$year = 1963;
-$is_dst = 0;
$extra_arg = 10;
-var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $is_dst, $extra_arg) );
+var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $extra_arg) );
?>
===DONE===
-- Testing mktime() function with more than expected no. of arguments --
-Warning: mktime() expects at most 7 parameters, 8 given in %s on line %d
+Warning: mktime() expects at most 6 parameters, 7 given in %s on line %d
bool(false)
===DONE===
+++ /dev/null
---TEST--
-Test mktime() function : usage variation - Passing unexpected values to seventh argument $is_dst.
---FILE--
-<?php
-/* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
- * Description: Get Unix timestamp for a date
- * Source code: ext/date/php_date.c
- * Alias to functions:
- */
-
-echo "*** Testing mktime() : usage variation - unexpected values to seventh argument \$is_dst***\n";
-
-//Set the default time zone
-date_default_timezone_set("Europe/London");
-
-//get an unset variable
-$unset_var = 10;
-unset ($unset_var);
-
-// define some classes
-class classWithToString
-{
- public function __toString() {
- return "Class A object";
- }
-}
-
-class classWithoutToString
-{
-}
-
-// heredoc string
-$heredoc = <<<EOT
-hello world
-EOT;
-
-// add arrays
-$index_array = array (1, 2, 3);
-$assoc_array = array ('one' => 1, 'two' => 2);
-
-// resource
-$file_handle = fopen(__FILE__, 'r');
-
-//array of values to iterate over
-$inputs = array(
-
- // int data
- 'int 0' => 0,
- 'int 0' => 1,
- 'int 0' => -1,
- 'int 12345' => 12345,
- 'int -12345' => -12345,
-
- // float data
- 'float 10.5' => 10.5,
- 'float -10.5' => -10.5,
- 'float .5' => .5,
-
- // array data
- 'empty array' => array(),
- 'int indexed array' => $index_array,
- 'associative array' => $assoc_array,
- 'nested arrays' => array('foo', $index_array, $assoc_array),
-
- // null data
- 'uppercase NULL' => NULL,
- 'lowercase null' => null,
-
- // boolean data
- 'lowercase true' => true,
- 'lowercase false' =>false,
- 'uppercase TRUE' =>TRUE,
- 'uppercase FALSE' =>FALSE,
-
- // empty data
- 'empty string DQ' => "",
- 'empty string SQ' => '',
-
- // string data
- 'string DQ' => "string",
- 'string SQ' => 'string',
- 'mixed case string' => "sTrInG",
- 'heredoc' => $heredoc,
-
- // object data
- 'instance of classWithToString' => new classWithToString(),
- 'instance of classWithoutToString' => new classWithoutToString(),
-
- // undefined data
- 'undefined var' => @$undefined_var,
-
- // unset data
- 'unset var' => @$unset_var,
-
- // resource
- 'resource' => $file_handle
-);
-
-$hour = 10;
-$minute = 30;
-$second = 45;
-$month = 7;
-$day = 2;
-$year = 1963;
-
-foreach($inputs as $variation =>$is_dst) {
- echo "\n-- $variation --\n";
- var_dump( mktime($hour, $minute, $second, $month, $day, $year, $is_dst) );
-};
-
-// closing the resource
-fclose( $file_handle );
-
-?>
-===DONE===
---EXPECTF--
-*** Testing mktime() : usage variation - unexpected values to seventh argument $is_dst***
-
--- int 0 --
-int(%i)
-
--- int 12345 --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- int -12345 --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- float 10.5 --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(-205165755)
-
--- float -10.5 --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- float .5 --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(-205162155)
-
--- empty array --
-
-Warning: mktime() expects parameter 7 to be integer, array given in %s on line %d
-bool(false)
-
--- int indexed array --
-
-Warning: mktime() expects parameter 7 to be integer, array given in %s on line %d
-bool(false)
-
--- associative array --
-
-Warning: mktime() expects parameter 7 to be integer, array given in %s on line %d
-bool(false)
-
--- nested arrays --
-
-Warning: mktime() expects parameter 7 to be integer, array given in %s on line %d
-bool(false)
-
--- uppercase NULL --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- lowercase null --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- lowercase true --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- lowercase false --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- uppercase TRUE --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- uppercase FALSE --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- empty string DQ --
-
-Warning: mktime() expects parameter 7 to be integer, string given in %s on line %d
-bool(false)
-
--- empty string SQ --
-
-Warning: mktime() expects parameter 7 to be integer, string given in %s on line %d
-bool(false)
-
--- string DQ --
-
-Warning: mktime() expects parameter 7 to be integer, string given in %s on line %d
-bool(false)
-
--- string SQ --
-
-Warning: mktime() expects parameter 7 to be integer, string given in %s on line %d
-bool(false)
-
--- mixed case string --
-
-Warning: mktime() expects parameter 7 to be integer, string given in %s on line %d
-bool(false)
-
--- heredoc --
-
-Warning: mktime() expects parameter 7 to be integer, string given in %s on line %d
-bool(false)
-
--- instance of classWithToString --
-
-Warning: mktime() expects parameter 7 to be integer, object given in %s on line %d
-bool(false)
-
--- instance of classWithoutToString --
-
-Warning: mktime() expects parameter 7 to be integer, object given in %s on line %d
-bool(false)
-
--- undefined var --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- unset var --
-
-Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
-int(%i)
-
--- resource --
-
-Warning: mktime() expects parameter 7 to be integer, resource given in %s on line %d
-bool(false)
-===DONE===