Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62724 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44172 invoked from network); 3 Sep 2012 11:49:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2012 11:49:50 -0000 Authentication-Results: pb1.pair.com header.from=wfitch@meetme.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=wfitch@meetme.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain meetme.com designates 74.125.149.197 as permitted sender) X-PHP-List-Original-Sender: wfitch@meetme.com X-Host-Fingerprint: 74.125.149.197 na3sys009aog107.obsmtp.com Linux 2.5 (sometimes 2.4) (4) Received: from [74.125.149.197] ([74.125.149.197:39830] helo=na3sys009aog107.obsmtp.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/54-20751-D5994405 for ; Mon, 03 Sep 2012 07:49:50 -0400 Received: from mail-vb0-f42.google.com ([209.85.212.42]) (using TLSv1) by na3sys009aob107.postini.com ([74.125.148.12]) with SMTP ID DSNKUESZWFvJLr5DWOYMlEGdUhrVTta3XdTu@postini.com; Mon, 03 Sep 2012 04:49:49 PDT Received: by vbbfs19 with SMTP id fs19so5665093vbb.29 for ; Mon, 03 Sep 2012 04:49:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=3t3bCanhBZDSg+zFFIHyn4jA9J+rrYRZ6vFXAJZVwrw=; b=fWs/t6iOxUhHYvNsGhZS2GOn/2VVkXPUIb/Xaq9VgVdW30oIEW45tnpV5OmdfZqMLV 8wa1G1l+JMlBxG48W7niBrHGEvZ+4j7/LfrlRQApUN8brqYPWmDsKFcxc4qMVXjvz9xU JXFarbzKydxu1vwScCkVasCsIZIqFeu7CB+OCY4boRzoigTL0giXDFayj055pyAdonY2 Q1kkgYKnRuUJxsZ4eOfaRxYdS/jx3rv5fYgG5JVkMsD476/Z+ZVpGwmprx67uF0xprDE t+YBO4vxFDd/jxD4zuIJCaPQsiPz72fISc52QQD6EtpLHB1VXsQvLCsLAsRxrjbqd3MI CuuQ== MIME-Version: 1.0 Received: by 10.220.209.80 with SMTP id gf16mr11934018vcb.58.1346672983659; Mon, 03 Sep 2012 04:49:43 -0700 (PDT) Received: by 10.58.132.161 with HTTP; Mon, 3 Sep 2012 04:49:43 -0700 (PDT) X-Originating-IP: [71.185.163.243] In-Reply-To: References: <5042BC3C.7070208@sugarcrm.com> <50435ABE.4010308@ajf.me> <50436412.7010802@ajf.me> <5043C3E9.2010105@ajf.me> <5043C5AF.3060701@ajf.me> <5043C74C.8020400@ajf.me> <5043D8C0.3020802@lsces.co.uk> Date: Mon, 3 Sep 2012 07:49:43 -0400 Message-ID: To: Derick Rethans Cc: Lester Caine , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=bcaec54ee282d1d5b704c8cabc03 X-Gm-Message-State: ALoCoQn+YbAazfkrL1fzNGUb43geqK5eTjh9AVScftN1mmIt//IG0NqlpTRzEnyezHCgUHov4q3F Subject: Re: [PHP-DEV] RFC for Adding __toString to DateTime From: wfitch@meetme.com (Will Fitch) --bcaec54ee282d1d5b704c8cabc03 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Sep 3, 2012 at 4:16 AM, Derick Rethans wrote: > On Sun, 2 Sep 2012, Will Fitch wrote: > > > On Sep 2, 2012 6:08 PM, "Lester Caine" wrote: > > > > > > Peter Cowburn wrote: > > >> > > >> Finally, why should "echo $datetime;" be expected to work at all, > > >> since 95% of the time it's only going to be echo'd plain like that for > > >> debugging purposes as we'll never pick the "right" format to use in > > >> everyone's code. When needing to set the "default" (read: > > >> per-instance) string format with something like setToStringFormat() or > > >> whatever, that becomes*more* work than just calling format(). > > > > > > > > > Hopefully Will now understands just how problematic his request is, and > > why it has not been implemented as yet. I'm with you but for a slightly > > different reason. I never run anything but UTC on the server. So I'm only > > displaying anything other than UTC when handling a client view of the > data. > > So I would normally be calling format with the client timezone data. > > > > It is problematic because that is what we choose to make it. Right now, > a > > catchable fatal error is produced. That is problematic. ISO8601 is not > > lossy nor is UTC. > > This tells me you haven't researched this subject properly. So let me > demonstrate once more: > $d = date_create( "2012-09-03 09:13:52" ); > var_dump( $d ); > $s = $d->format( DateTime::ISO8601 ); > $d = date_create( $s ); > var_dump( $d ); > > Outputs: > > class DateTime#1 (3) { > public $date => > string(19) "2012-09-03 09:13:52" > public $timezone_type => > int(3) > public $timezone => > string(13) "Europe/London" > } > > class DateTime#2 (3) { > public $date => > string(19) "2012-09-03 09:13:52" > public $timezone_type => > int(1) > public $timezone => > string(6) "+01:00" > } > > And voila, you've just lost the timezone that belongs to the DateTime > object. > You have an accurate representation of the ISO format - which does not specify the string representation of a timezone, but rather the offset of UTC. This is not lossy. The DateTime object still maintains its integrity - and includes the offset (if present). The toString representation is not a serialized format of every attachment of the entire object - it's a string representation. You actually helped prove the case for ISO-8601, IMHO. You were able to take the date, time and UTC offset and accomplish the same goal; all of this from the toString format! > > > We have standards for a reason. I agree that changing that should not > > be allowed. I will remove the set/get pattern functions and only print > > a standard format. Printing an ISO standard format, which includes the > > TZ based on UTC, or even the UTC format itself is a better solution > > than a catchable fatal error. > > I disagree as it is an Ostrich Method. Instead of fixing your problem > you'll just be hiding it. > > Derick > --bcaec54ee282d1d5b704c8cabc03--