Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62631 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27478 invoked from network); 1 Sep 2012 11:31:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Sep 2012 11:31:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:44769] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/C1-17065-302F1405 for ; Sat, 01 Sep 2012 07:31:16 -0400 Received: by lahl5 with SMTP id l5so2817152lah.29 for ; Sat, 01 Sep 2012 04:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=eUQWwEXR4xQq/tSY/k7Hz35i9Ce3IneQxZVzSLQ76qs=; b=dJN64amFazIT0nax6aFn0UJx7LfEAZirnJ4LXY5R4O/8CaQy68WlUBM9i1O4teUieR tfBnmg2eDJnYh0IOS5xGfaDJtlwKeDo06UxKZAfgn1V48YNIusaY5HIBmsG9SyKAoXyx RnEpXaV9TtM+/iMcMfH4Mb4T2+ugzCST6eD04u+WnYjyL/R9x73e2gWf2pz44QoTDP9H BSFyf+ATbzoH9OXTX1sBxtO7+H9OXn5vLJmRM6cTKXTLRmWKJa1n2pGPtttiUXsrXulC 7v2cltAP8QYahsrA+EtlwLiUFzi2jmYOfBxbB7wtF9+kUDqAtAfzhxuQSrrh3Bbwm7CP hwtg== MIME-Version: 1.0 Received: by 10.152.125.116 with SMTP id mp20mr9015287lab.19.1346499071483; Sat, 01 Sep 2012 04:31:11 -0700 (PDT) Received: by 10.112.8.7 with HTTP; Sat, 1 Sep 2012 04:31:11 -0700 (PDT) In-Reply-To: References: Date: Sat, 1 Sep 2012 07:31:11 -0400 Message-ID: To: Will Fitch Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] RFC for Adding __toString to DateTime From: theanomaly.is@gmail.com (Sherif Ramadan) On Sat, Sep 1, 2012 at 6:14 AM, 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 link to the RFC and patch are here: > https://wiki.php.net/rfc/datetime_tostring. > > While I know this isn't as interesting as many of the current proposals > going on, I'm hoping you can give this RFC a look. > > - Will I think you should consider making the get/setDefaultPattern() methods into a public string called $format and just put it in the constructor with an initial value of DateTime::ISO8601 It'd be a much simple implementation and doesn't require introducing new functions. DateTime can either throw an exception if the format is invalid or silently fall back to the DateTime::ISO8601 No need to complicate this.