Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53350 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23491 invoked from network); 16 Jun 2011 23:51:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jun 2011 23:51:14 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.153 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.153 smtp153.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.153] ([67.192.241.153:54671] helo=smtp153.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/CC-47775-1F69AFD4 for ; Thu, 16 Jun 2011 19:51:14 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp5.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 3148B58D07; Thu, 16 Jun 2011 19:51:10 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp5.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id CDECC58570; Thu, 16 Jun 2011 19:51:09 -0400 (EDT) Message-ID: <4DFA96ED.90800@sugarcrm.com> Date: Thu, 16 Jun 2011 16:51:09 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: PHP Internals CC: Derick Rethans Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: date_diff broken? From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! I've been looking into various tests and discovered something strange in date_diff. Example code: diff($end); var_dump($start); As a result of this I'm getting this: object(DateTime)#1 (3) { ["date"]=> string(19) "2010-10-04 06:18:48" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "EDT" } As you can see, the date in $start changed, even though it shouldn't happen. Looks like it's because of timelib_diff() which has this: timelib_apply_localtime(one, 0); timelib_apply_localtime(two, 0); which converts times in diff arguments to localtime. It then does: timelib_apply_localtime(one, 1); timelib_apply_localtime(two, 1); which is supposed to convert them back, but in fact it does not, since first conversion seems to have killed TZ information. I'd propose to fix it by making time_diff operate on copies of one and two instead of real structures, but maybe somebody has a better idea? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227