On Sun, 2 Sep 2012, Will Fitch wrote: > On Sat, Sep 1, 2012 at 4:54 PM, Derick Rethans <der...@php.net> 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?
$ php -r 'echo date_create()->format( DateTime::ISO8601 );' 2012-09-02T12:26:17+0100 ^^^^^ is the lossless bit. It tells you nothing about the timezone. This is why var_dump(date_create()) has: public $timezone => string(13) "Europe/London" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > ISO-8601 is only output *if* there is no pre-set pattern provided. So > in essance, 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. Right, it's so simple that it can be done in userland in 4 lines of code. I don't want to add this. 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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php