Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62655 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12371 invoked from network); 2 Sep 2012 04:08:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 04:08:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=wfitch@meetme.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=wfitch@meetme.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain meetme.com designates 74.125.149.207 as permitted sender) X-PHP-List-Original-Sender: wfitch@meetme.com X-Host-Fingerprint: 74.125.149.207 na3sys009aog112.obsmtp.com Linux 2.5 (sometimes 2.4) (4) Received: from [74.125.149.207] ([74.125.149.207:36754] helo=na3sys009aog112.obsmtp.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/00-17065-EABD2405 for ; Sun, 02 Sep 2012 00:08:15 -0400 Received: from mail-vb0-f42.google.com ([209.85.212.42]) (using TLSv1) by na3sys009aob112.postini.com ([74.125.148.12]) with SMTP ID DSNKUELbq09qv/P3RfAz0240cIkJh9rHV2Zd@postini.com; Sat, 01 Sep 2012 21:08:14 PDT Received: by vbbfs19 with SMTP id fs19so4768846vbb.29 for ; Sat, 01 Sep 2012 21:08:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:x-originating-ip:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=D6CtqeLYwmCxuwJnCE3uDmBT01XXflG3eWwYhnMjrVA=; b=jj3GfT1lm1Lu8kfOrwtAT1lG+YUS7sj5pwkcbBbnv1odUN/3o9gTD0FG7ShDfhYKKo EplytvtdK4ei1Re0F3Dwok5zYMmC/erQCHgkqFWV08tGS9lmX7c0N5Wx/RDpz5sMtrgw 33oZf3Z55vRw6crd6OSNu/kpnC5PjibOCbGTUoZwO+Nmrh94ymZ91VMM9mfPpJesO1Op atTbizEyhqQMbAhOMW1tX/u7dT6rDztHYvr9fTUzdQXrg9ZSohp4PZ2evuRGtQRTZ4YM cOS5D4jcKn/fvXkqejAGAech4+KUHt1PXPPcNp+tW4cJ29Lrj4rvw367xpHVuUthyTL+ gR+Q== MIME-Version: 1.0 Received: by 10.221.10.148 with SMTP id pa20mr8973877vcb.26.1346558890466; Sat, 01 Sep 2012 21:08:10 -0700 (PDT) Sender: wfitch@meetme.com Received: by 10.58.132.161 with HTTP; Sat, 1 Sep 2012 21:08:10 -0700 (PDT) X-Originating-IP: [71.185.163.243] In-Reply-To: References: Date: Sun, 2 Sep 2012 00:08:10 -0400 X-Google-Sender-Auth: gU_x-5rUTyfoP8xCaYQnFBkpUwo Message-ID: To: Derick Rethans Cc: PHP Developers Mailing List Content-Type: multipart/alternative; boundary=bcaec54d4e0a55dd5504c8b02c65 X-Gm-Message-State: ALoCoQm1B3ciFxrhtiv92ewSFxypDy9RsTc9gG3lbDK0v6C5yhKQLXew2JBxFlaBO+qmxlt0PQQz Subject: Re: [PHP-DEV] RFC for Adding __toString to DateTime From: willfitch@php.net (Will Fitch) --bcaec54d4e0a55dd5504c8b02c65 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Sep 1, 2012 at 4:54 PM, Derick Rethans wrote: > On Sat, 1 Sep 2012, Will Fitch wrote: > > > I would like to officially introduce an RFC with a patch to implement > > __toString to DateTime. This is a commonly requested feature that goes > > unanswered mostly because of the inability to agree on a default pattern. > > > > In short, the patch uses the ISO-8601 format as the default pattern. The > > pattern may be changed via setDefaultPattern and > date_default_pattern_set, > > as explained in the RFC. > > The default should most definitely not be ISO-8601 - as it's a lossy > format. > In terms of lossy transmission/storage, what concerns in regards to the pattern are you referring to? ISO-8601 is only output *if* there is no pre-set pattern provided. So in essance, > > > The link to the RFC and patch are here: > > https://wiki.php.net/rfc/datetime_tostring. > > > Methods Added > > > > void DateTime::setDefaultPattern(string $pattern) > > string DateTime::getDefaultPattern(void) > > This should be descriptive. You are *only* dealing with __toString here. > Hence the method names should reflect that: > > void DateTime::setToStringFormat(string $pattern) > string DateTime::getToStringFormat(void) > However, I still don't believe this belongs in the class at all. It is > rather trivial to do this in userland: > > class MyDateTime extends DateTime { > static $format = "... some format..."; > function __toString() { return $this->format(DateTime::$format); } > } > > There, 4 lines. And no quaralling about formats or naming. > I'm definitely not sold on any naming convention or format, and I don't see any quarrelling going on. The purpose of the RFC is to come up with a solution and discuss implementation. I don't expect any quarrels for something this simple. I would like this discussed. This is a feature often brought up and requested. I understand that it may be difficult to come to a solution, but let's try. > > > > $date = new DateTime('2012-09-01 02:43:00'); > > print_r($date); > > Should not output just: > > > DateTime Object > > ( > > [date] => 2012-09-01 02:43:00 > > [timezone_type] => 3 > > [timezone] => America/Chicago > > ) > > But instead should always have the tostring pattern in there. > I agree and will update. > > Also, have you checked whether it shows up when you run serialize on it? > The patch I originally wrote did implement wakeup and set state. Unfortunately, an accidental git checkout -- in the wrong path gave me the distinct pleasure of rewriting this. > > cheers, > Derick > --bcaec54d4e0a55dd5504c8b02c65--