Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62731 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54149 invoked from network); 3 Sep 2012 12:09:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2012 12:09:24 -0000 Authentication-Results: pb1.pair.com header.from=lars@strojny.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lars@strojny.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain strojny.net from 46.4.40.248 cause and error) X-PHP-List-Original-Sender: lars@strojny.net X-Host-Fingerprint: 46.4.40.248 milch.schokokeks.org Received: from [46.4.40.248] ([46.4.40.248:39399] helo=milch.schokokeks.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/96-20751-2FD94405 for ; Mon, 03 Sep 2012 08:09:23 -0400 Received: from [192.168.1.102] (p5099f5c8.dip0.t-ipconnect.de [::ffff:80.153.245.200]) (AUTH: PLAIN lars@schokokeks.org, TLS: TLSv1/SSLv3,128bits,AES128-SHA) by milch.schokokeks.org with ESMTPSA; Mon, 03 Sep 2012 14:09:19 +0200 id 0000000000000023.0000000050449DEF.000039E0 Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 6.0 \(1485\)) In-Reply-To: Date: Mon, 3 Sep 2012 14:09:16 +0200 Cc: Will Fitch , Ryan McCue , internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: CAArmra3vLz_NhnXPzWUwgKjRSk7HifXry39_77R4Fd6FiiTamQ@mail.gmail.com> To: Pierre Joye X-Mailer: Apple Mail (2.1485) Subject: Re: [PHP-DEV] RFC for Adding __toString to DateTime From: lars@strojny.net (Lars Strojny) Hi Pierre, hi Will, Am 03.09.2012 um 13:57 schrieb Pierre Joye : > hi Will, >=20 > On Mon, Sep 3, 2012 at 1:51 PM, Will Fitch wrote: >> On Mon, Sep 3, 2012 at 4:59 AM, Ryan McCue = wrote: >>=20 >>> As far as I can tell, there's no standard which uses the Olson = database >>> to specify the timezone, so we'd have to create one. >>>=20 >>> What about ISO8601 with the Olson timezone suffixed? >>>=20 >>> 2012-09-02T18:17:36+0100 (Europe/London) >>> 2012-09-02T18:19:05+0100 (Africa/Niamey) >>>=20 [...] >=20 > I don't think you will ever get a consensus on that. The reason is > that this case falls in the same fall than the timezone itself (but > per instance of an object instead of globally). >=20 > I'd to suggest to force the definition of a format using the > setStringFormat (or whatever will be the name of this function). > __toString will then fail if no format has been set, warning and > returns NULL (f.e.). I don=92t agree here, especially if we recap what the proposed purpose = of the __toString() method was: Ease debugging by allowing "echo $date;" instead of "echo = $date->format(...);" An additional constraint to make sure users use it for debugging and = nothing else, would be: Not allow changing the format, neither by ini setting or any other = global means (incl. setters) To achieve that, we need a time format that is best for debugging, = meaning, as lossless as possible. While ISO8601 comes pretty close it = misses out on the Olson timezone suffix. I would second the notion of = creating our own format and standardizing it internally with it=92s own = constant and DateTime doing the right thing if passed to the = constructor. Additionally to what Ryan proposed, microseconds should be = part of it (which ISO allows). So, here we go: 2012-09-02T18:17:36.12345+0100 (Europe/London) Following this, the change would be fairly easy (adding a constant, a = bit parsing fu and the toString() method). cu, Lars=