Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53351 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 939 invoked from network); 17 Jun 2011 09:18:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2011 09:18:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:49715] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/62-17668-BFB1BFD4 for ; Fri, 17 Jun 2011 05:18:51 -0400 Received: by qyk32 with SMTP id 32so405614qyk.8 for ; Fri, 17 Jun 2011 02:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=s6snXsukWbZH7niXcreO+WrBMv8haETivFKH/xRURkk=; b=YLjm+8skD7+8JJv1herXO8fG8EROi+JTJEob1xJLfNKpOiEyy8H6JTk/a62KANNYrs o0ECB15p86necUlzbnZvin5QxeIBvtK9Xpb+HXNC63spHfxVE/Trre4m5ksx7YwyWdEc Ips2sQn82QS+R4f+ApYH87WrWSJO3oWNuH6uc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=duFvP3iZ21kbKcg60COJQePxck1VdWBufDo44zpZAapJC3AQpnc60kOlkWe2cNjzEA qtz+KklCTTtRUn9oYL/Tbo/EmkxEYVrzt6ftyiLr2Mt/mgb6lK1N3oUuCjIStqCKpFn3 DuYjWjVX9m4jcfn0JsXNHdeM5JN4tqSvTALyI= Received: by 10.224.201.67 with SMTP id ez3mr1522329qab.111.1308302327820; Fri, 17 Jun 2011 02:18:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.80.79 with HTTP; Fri, 17 Jun 2011 02:18:26 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: <4DFA96ED.90800@sugarcrm.com> References: <4DFA96ED.90800@sugarcrm.com> Date: Fri, 17 Jun 2011 10:18:26 +0100 Message-ID: To: Stas Malyshev Cc: PHP Internals , Derick Rethans Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] date_diff broken? From: rquadling@gmail.com (Richard Quadling) On 17 June 2011 00:51, Stas Malyshev wrote: > Hi! > > I've been looking into various tests and discovered something strange in > date_diff. Example code: > > $start =3D new DateTime('2010-10-04 02:18:48 EDT'); > $end =C2=A0 =3D new DateTime('2010-11-06 18:38:28 EDT'); > $int =3D $start->diff($end); > var_dump($start); > > As a result of this I'm getting this: > > object(DateTime)#1 (3) { > =C2=A0["date"]=3D> > =C2=A0string(19) "2010-10-04 06:18:48" > =C2=A0["timezone_type"]=3D> > =C2=A0int(2) > =C2=A0["timezone"]=3D> > =C2=A0string(3) "EDT" > } > > As you can see, the date in $start changed, even though it shouldn't happ= en. > Looks like it's because of timelib_diff() which has this: > > =C2=A0 =C2=A0timelib_apply_localtime(one, 0); > =C2=A0 =C2=A0timelib_apply_localtime(two, 0); > > which converts times in diff arguments to localtime. It then does: > > =C2=A0 =C2=A0timelib_apply_localtime(one, 1); > =C2=A0 =C2=A0timelib_apply_localtime(two, 1); > > which is supposed to convert them back, but in fact it does not, since fi= rst > 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? Just ran Stas' script against a lot of 5.3's. V5.3.0alpha2 : string(19) "2010-10-04 06:18:48" V5.3.0alpha3 : string(19) "2010-10-04 06:18:48" V5.3.0beta1 : string(19) "2010-10-04 06:18:48" V5.3.0RC2 : string(19) "2010-10-04 06:18:48" V5.3.0RC3 : string(19) "2010-10-04 06:18:48" V5.3.0RC4 : string(19) "2010-10-04 06:18:48" V5.3.0 : string(19) "2010-10-04 06:18:48" V5.3.1RC1 : string(19) "2010-10-04 06:18:48" V5.3.1RC2 : string(19) "2010-10-04 06:18:48" V5.3.1RC3 : string(19) "2010-10-04 06:18:48" V5.3.1RC4 : string(19) "2010-10-04 06:18:48" V5.3.1 : string(19) "2010-10-04 06:18:48" V5.3.2RC1 : string(19) "2010-10-04 06:18:48" V5.3.2RC2 : string(19) "2010-10-04 06:18:48" V5.3.2RC3 : string(19) "2010-10-04 06:18:48" V5.3.2 : string(19) "2010-10-04 06:18:48" V5.3.3RC1 : string(19) "2010-10-04 06:18:48" V5.3.3RC2 : string(19) "2010-10-04 06:18:48" V5.3.3RC3 : string(19) "2010-10-04 06:18:48" V5.3.3 : string(19) "2010-10-04 06:18:48" V5.3.4RC1 : string(19) "2010-10-04 06:18:48" V5.3.4RC2 : string(19) "2010-10-04 06:18:48" V5.3.4 : string(19) "2010-10-04 06:18:48" V5.3.5 : string(19) "2010-10-04 06:18:48" V5.3.6RC1 : string(19) "2010-10-04 06:18:48" V5.3.6RC2 : string(19) "2010-10-04 06:18:48" V5.3.6RC3 : string(19) "2010-10-04 06:18:48" V5.3.6 : string(19) "2010-10-04 06:18:48" Even though the behaviour is wrong, it is consistent. There are no user notes commenting on this issue in the documentation. Can't check the bug base at the moment due to it being down. If either of the dates use a TLA timezone (EDT, PST, GMT), rather than the long name (Europe/London, Indian/Kerguelen, America/Kentucky/Louisville), then that date is altered. Richard. --=20 Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea