Date: 06/11/99
- Next message: Sascha Schumann: "Re: [PHP-DEV] Bug #1529: gmmktime is broken"
- Previous message: Andrey Zmievski: "[PHP-DEV] dl() problem"
- Next in thread: Sascha Schumann: "Re: [PHP-DEV] Bug #1529: gmmktime is broken"
- Reply: Sascha Schumann: "Re: [PHP-DEV] Bug #1529: gmmktime is broken"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: egon <email protected>
Operating system: Linux
PHP version: 3.0.9
PHP Bug Type: Misbehaving function
Bug description: gmmktime is broken
in functions/datetime.c, the code for translate to GMT is broken. The (I think) fixed version would look like this:
void _php3_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
{
pval *arguments[6];
struct tm ta, *tn;
time_t t;
int i, gmadjust=0,arg_count = ARG_COUNT(ht);
if (arg_count > 6 || getParametersArray(ht, arg_count, arguments) == FAI
LURE) {
WRONG_PARAM_COUNT;
}
/* convert supplied arguments to longs */
for (i = 0; i < arg_count; i++) {
convert_to_long(arguments[i]);
}
t=time(NULL);
#if HAVE_TZSET
tzset();
#endif
tn = localtime(&t);
memcpy(&ta,tn,sizeof(struct tm));
ta.tm_isdst = -1;
switch(arg_count) {
case 6:
ta.tm_year = arguments[5]->value.lval - ((arguments[5]->value.lv
al > 1000) ? 1900 : 0);
/* fall-through */
case 5:
ta.tm_mday = arguments[4]->value.lval;
/* fall-through */
case 4:
ta.tm_mon = arguments[3]->value.lval - 1;
/* fall-through */
case 3:
ta.tm_sec = arguments[2]->value.lval;
/* fall-through */
case 2:
ta.tm_min = arguments[1]->value.lval;
/* fall-through */
case 1:
ta.tm_hour = arguments[0]->value.lval/* - gmadjust*/;
case 0:
break;
}
t=mktime(&ta); /* Need to do this because of Daylight savings */
tn = localtime(&t);
if (gm) {
#if HAVE_TM_GMTOFF
gmadjust=(tn->tm_gmtoff)/3600;
#else
gmadjust=timezone/3600;
#endif
}
ta.tm_hour+=gmadjust;
return_value->value.lval = mktime(&ta);
return_value->type = IS_LONG;
}
-- PHP Development Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Sascha Schumann: "Re: [PHP-DEV] Bug #1529: gmmktime is broken"
- Previous message: Andrey Zmievski: "[PHP-DEV] dl() problem"
- Next in thread: Sascha Schumann: "Re: [PHP-DEV] Bug #1529: gmmktime is broken"
- Reply: Sascha Schumann: "Re: [PHP-DEV] Bug #1529: gmmktime is broken"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

