ID: 19583 Updated by: [EMAIL PROTECTED] Reported By: at217 at chebucto dot ns dot ca -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: Linux PHP Version: 4.2.3 New Comment:
This mess is fixed with the new date handling, introduced with PHP 5.1. The 'is_dst' parameter became also deprecated. Previous Comments: ------------------------------------------------------------------------ [2002-09-24 16:50:22] at217 at chebucto dot ns dot ca Here's one way to make the suggested change, if anyone cares to commit it: *** datetime.c-orig Tue Sep 24 16:18:27 2002 --- datetime.c Tue Sep 24 18:35:03 2002 *************** *** 83,93 **** struct tm *ta, tmbuf; time_t t; int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); - int is_dst = -1; if (arg_count > 7 || zend_get_parameters_array_ex(arg_count, arguments) == FAILURE) { WRONG_PARAM_COUNT; } /* convert supplied arguments to longs */ for (i = 0; i < arg_count; i++) { convert_to_long_ex(arguments[i]); --- 83,97 ---- struct tm *ta, tmbuf; time_t t; int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); if (arg_count > 7 || zend_get_parameters_array_ex(arg_count, arguments) == FAILURE) { WRONG_PARAM_COUNT; } + if (gm && arg_count == 7) { + // TO DO: issue a warning here, but keep going (so WRONG_PARAM_COUNT won't work) + arg_count--; + } + /* convert supplied arguments to longs */ for (i = 0; i < arg_count; i++) { convert_to_long_ex(arguments[i]); *************** *** 119,125 **** */ switch(arg_count) { case 7: ! ta->tm_isdst = is_dst = Z_LVAL_PP(arguments[6]); /* fall-through */ case 6: /* special case: --- 123,129 ---- */ switch(arg_count) { case 7: ! ta->tm_isdst = Z_LVAL_PP(arguments[6]); /* fall-through */ case 6: /* special case: *************** *** 169,176 **** } seconds = mktime(ta); - if (is_dst == -1) - is_dst = ta->tm_isdst; if (gm) { #if HAVE_TM_GMTOFF --- 173,178 ---- *************** *** 185,193 **** ** the value of timezone - 3600 seconds. */ #ifdef __CYGWIN__ ! gmadjust = -(is_dst ? _timezone - 3600 : _timezone); #else ! gmadjust = -(is_dst ? timezone - 3600 : timezone); #endif #endif seconds += gmadjust; --- 187,195 ---- ** the value of timezone - 3600 seconds. */ #ifdef __CYGWIN__ ! gmadjust = -(ta->tm_isdst ? _timezone - 3600 : _timezone); #else ! gmadjust = -(ta->tm_isdst ? timezone - 3600 : timezone); #endif #endif seconds += gmadjust; *************** *** 197,203 **** } /* }}} */ ! /* {{{ proto int mktime(int hour, int min, int sec, int mon, int day, int year) Get UNIX timestamp for a date */ PHP_FUNCTION(mktime) { --- 199,205 ---- } /* }}} */ ! /* {{{ proto int mktime(int hour, int min, int sec, int mon, int day, int year, int is_dst) Get UNIX timestamp for a date */ PHP_FUNCTION(mktime) { ------------------------------------------------------------------------ [2002-09-24 16:39:48] at217 at chebucto dot ns dot ca Passing anything but -1 for the is_dst argument of gmmktime can result in times that are off by an hour, if the system's local time zone uses DST. For example, I assumed that passing 0 would the right thing to do (not in DST), but if the date falls within my local DST range, the time I get back is an hour ahead. This is because, internally, PHP calls mktime and then tries to adjust the local time to GMT. Of course, this is easy enough to work around, and I will put a note on the manual page, but I still think the parameter is irrelevant for gmmktime, and since its use can cause errors, it would be nice if it were removed, or at least ignored (if one wants to avoid breaking existing code; although a warning would probably be good). /* Demostrate problem with gmmktime() */ // These should produce the same value, as GMT has no DST. echo gmmktime(0, 0, 0, 7, 23, 2002, 0) ."\n"; echo gmmktime(0, 0, 0, 7, 23, 2002) . "\n"; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19583&edit=1