Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13828 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56455 invoked by uid 1010); 12 Nov 2004 22:14:22 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 56381 invoked from network); 12 Nov 2004 22:14:21 -0000 Received: from unknown (HELO marvin.mindnever.org) (80.74.160.83) by pb1.pair.com with SMTP; 12 Nov 2004 22:14:21 -0000 Received: (qmail 16706 invoked by uid 509); 12 Nov 2004 22:02:05 -0000 Received: from bunuel-cpe-185-bgd.sbb.co.yu (HELO mravojed.office.kom) (82.117.196.185) by marvin.mindnever.org with SMTP; 12 Nov 2004 22:02:02 -0000 To: internals@lists.php.net Content-Type: text/plain Organization: MindNever Dot Org Message-ID: <1100297627.8313.50.camel@mravojed> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 12 Nov 2004 23:13:48 +0100 Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on leya.mindnever.org X-Spam-Level: X-Spam-Status: No, hits=-2.8 required=4.0 tests=AWL,BAYES_00,RCVD_IN_SBL, SUBJ_HAS_UNIQ_ID autolearn=no version=2.63 Subject: Fix for php4 bug #30096 From: vladimir@mindnever.org (Vladimir Zidar) 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);