Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13862 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8676 invoked by uid 1010); 15 Nov 2004 15:05:13 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 8636 invoked from network); 15 Nov 2004 15:05:12 -0000 Received: from unknown (HELO marvin.mindnever.org) (80.74.160.83) by pb1.pair.com with SMTP; 15 Nov 2004 15:05:12 -0000 Received: (qmail 4021 invoked by uid 509); 15 Nov 2004 15:55:48 -0000 Received: from bunuel-cpe-185-bgd.sbb.co.yu (HELO mravojed.office.kom) (82.117.196.185) by marvin.mindnever.org with SMTP; 15 Nov 2004 15:55:45 -0000 To: internals@lists.php.net Cc: derick@php.net Content-Type: text/plain Organization: MindNever Dot Org Message-ID: <1100531086.4084.9.camel@mravojed> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 15 Nov 2004 16:04:46 +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 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);