Fix for php4 bug #30096

From: Date: Fri, 12 Nov 2004 22:13:48 +0000
Subject: Fix for php4 bug #30096
Groups: php.internals 
Request: Send a blank email to internals+get-13828@lists.php.net to get a copy of this message
If anybody (derick?) cares, gmmktime returning completly bogus results. It can be easly checked out by manually setting TZ shell variable. Lets try it like this: TZ=GMT+1 php -r "echo gmmktime();" gives 1100292805 TZ=GMT+2 php -r "echo gmmktime();" gives 1100289207 TZ=GMT+3 php -r "echo gmmktime();" gives 1100285610 But it should return always the same time (ok, few seconds here and there, needed to type each command..) no matter which timezone is set. Why ? Because 'tm_gmtoff' (and gmadjust manually calculated from 'timezone' and 'is_dst' in cases where tm_gmtoff is not available) shows number of seconds EAST from GMT (man localtime is your friend here). So to get GMT time from, we have to _substract_ this number from localtime, and what is php currently doing, is adding it to localtime, which can't be a good thing no matter how you look at it (-: So the fix is easy: --- ext/standard/datetime.c.orig Fri Nov 12 22:35:04 2004 +++ ext/standard/datetime.c Fri Nov 12 22:35:33 2004 @@ -256,7 +256,7 @@ gmadjust = -(is_dst ? timezone - 3600 : timezone); #endif #endif - seconds += gmadjust; + seconds -= gmadjust; } RETURN_LONG(seconds);

« previous php.internals (#13828) next »