Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62667 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52500 invoked from network); 2 Sep 2012 11:35:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 11:35:10 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:34750] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/F6-17065-D6443405 for ; Sun, 02 Sep 2012 07:35:09 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 1A41EDE13E; Sun, 2 Sep 2012 12:35:07 +0100 (BST) Date: Sun, 2 Sep 2012 12:35:06 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Will Fitch cc: Stas Malyshev , "internals@lists.php.net" In-Reply-To: Message-ID: References: <5042BC3C.7070208@sugarcrm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] RFC for Adding __toString to DateTime From: derick@php.net (Derick Rethans) On Sun, 2 Sep 2012, Will Fitch wrote: > On Sat, Sep 1, 2012 at 9:54 PM, Stas Malyshev 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. > > > > 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. > > > > This has been on my mind as well. I've considered that maybe an INI > wide setting would be beneficial here. We should absolutely NOT add ini settings for this. They make things unportable. > 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? Inherit it in userland! cheers, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug Posted with an email client that doesn't mangle email: alpine