Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62656 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13851 invoked from network); 2 Sep 2012 04:14:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 04:14:33 -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.18 as permitted sender) X-PHP-List-Original-Sender: wfitch@meetme.com X-Host-Fingerprint: 74.125.149.18 na3sys009aog137.obsmtp.com Linux 2.5 (sometimes 2.4) (4) Received: from [74.125.149.18] ([74.125.149.18:33822] helo=na3sys009aog137.obsmtp.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/60-17065-42DD2405 for ; Sun, 02 Sep 2012 00:14:32 -0400 Received: from mail-vc0-f170.google.com ([209.85.220.170]) (using TLSv1) by na3sys009aob137.postini.com ([74.125.148.12]) with SMTP ID DSNKUELdIrZU8tGQ30+Zf9QaIpscmCJG6u8i@postini.com; Sat, 01 Sep 2012 21:14:32 PDT Received: by vcbgb30 with SMTP id gb30so4969014vcb.29 for ; Sat, 01 Sep 2012 21:14:25 -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=PpbHVl/2zKZHkqWH7XjdM4PilbdiFfFnLq9IxE8+yqA=; b=OtwWRhjgdNFPm+Ab9p3VXJZfoVUPipEx9OlbScXQ8J9l9ZBRrXeM6bOEoQbChcSk4b TBOTp2H/7OsFcg4foDCSjJ6cZc7NUeOFm5zjv9d3V/+PqygsUuDl/OkNY4TtOZdWtDcm no3LpZ+NT9t/qXlz2KG6ZxZW30+Mbau43xPoF3uvz4HV2yUU57jSdz0LhTilDzmLemk0 l39SYcRycV8dTZsR/WVxU93StFcPC+9sSrlhcVvLylXnKbNIhZdzNx2RIXGspbHYdn+H Qc0+T5pA5TF5jM5NUviczu8e4ebHBBa3cZHGs2f0Du2/3i2X68t+8QgRb4qSYK5/9NUi 4rdg== MIME-Version: 1.0 Received: by 10.220.209.80 with SMTP id gf16mr8992028vcb.58.1346559265325; Sat, 01 Sep 2012 21:14:25 -0700 (PDT) Received: by 10.58.132.161 with HTTP; Sat, 1 Sep 2012 21:14:25 -0700 (PDT) X-Originating-IP: [71.185.163.243] In-Reply-To: <5042BC3C.7070208@sugarcrm.com> References: <5042BC3C.7070208@sugarcrm.com> Date: Sun, 2 Sep 2012 00:14:25 -0400 Message-ID: To: Stas Malyshev Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=bcaec54ee282adc21804c8b042c1 X-Gm-Message-State: ALoCoQlFHqiHpTswFFTrxkJE0d70TUXO8EactBpOQHwvxULw7hJNtELy2kALxJgPQ0xuEYiG94MW Subject: Re: [PHP-DEV] RFC for Adding __toString to DateTime From: wfitch@meetme.com (Will Fitch) --bcaec54ee282adc21804c8b042c1 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Sep 1, 2012 at 9:54 PM, Stas Malyshev wrote: > Hi! > > > 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. > > This must indicate there's actually no default pattern that is "default" > for everyone. Which suggests maybe we shouldn't have default string > conversion there? > After all, nothing prevents one from having: > > class MyDateTime extends DateTime { > public function __toString() { > return $this->format(/* whatever my favorite format is */); > } > } > > I'm not sure introducing special state to DateTime for it is the best > way to handle it. Also, most applications would have common date format > - which means since the state is per DateTime object, they'd have to > watch that every object produced would have this property set. I think > it'd be easier to just use DateTime->format() - this way you know what > is produced and it is clear for whoever is reading the code too. > Hi, Stas. This has been on my mind as well. I've considered that maybe an INI wide setting would be beneficial here. In fact, there are many places within applications I've worked on where the format for many DateTime objects are the same. What are your thoughts on that? > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > --bcaec54ee282adc21804c8b042c1--