Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62652 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3482 invoked from network); 2 Sep 2012 01:54:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 01:54:10 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.113 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.113 smtp113.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.113] ([67.192.241.113:53158] helo=smtp113.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/CE-17065-04CB2405 for ; Sat, 01 Sep 2012 21:54:09 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp11.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 701BAD1053; Sat, 1 Sep 2012 21:54:05 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp11.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 27842D0EC4; Sat, 1 Sep 2012 21:54:05 -0400 (EDT) Message-ID: <5042BC3C.7070208@sugarcrm.com> Date: Sat, 01 Sep 2012 18:54:04 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: Will Fitch CC: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC for Adding __toString to DateTime From: smalyshev@sugarcrm.com (Stas Malyshev) 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. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227