Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64233 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8241 invoked from network); 10 Dec 2012 19:41:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2012 19:41:42 -0000 Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-wg0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:58540] helo=mail-wg0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/E7-60401-3FA36C05 for ; Mon, 10 Dec 2012 14:41:40 -0500 Received: by mail-wg0-f42.google.com with SMTP id dr1so997709wgb.5 for ; Mon, 10 Dec 2012 11:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=ahItyLh8zW6P6urmtvWEGke6hrOvsFowYT/o+xFANms=; b=RnxTiy40LUgO93EHxwZESPqM70c8UZApJzjnyVtHIyqUNj2TngG7F/erxy6mW6BNPP M2fqnp4yRhj266Z9l8+No08981nLgzF+44nBrJ2YJmRAVqbrdvhbvGwTiliwl+MNI0rH bGjPSXW2Ca2s9VAPG1wym6n776d2wDmTFmugXAWp+zxcrfZi4hpQhpRRaRAAuYg98RoF PB2HbdoKjuJTsi1PPsyAo7fzbqyWCRFKrfk1I4Jtp0CEOAtk4gDRz+k0NX3ml70BEbRI U0DKxDi1WZoPCsNra+5H83uRj1ItE0hNRrj0Nw1bkUygvj+GTsOKhpKqN+r5fMvx6/HD 3Emg== Received: by 10.180.95.228 with SMTP id dn4mr7824353wib.16.1355168496987; Mon, 10 Dec 2012 11:41:36 -0800 (PST) Received: from [192.168.1.26] (54.Red-83-55-231.dynamicIP.rima-tde.net. [83.55.231.54]) by mx.google.com with ESMTPS id p2sm13032082wic.7.2012.12.10.11.41.35 (version=SSLv3 cipher=OTHER); Mon, 10 Dec 2012 11:41:36 -0800 (PST) Message-ID: <50C63A7C.8090705@gmail.com> Date: Mon, 10 Dec 2012 20:39:40 +0100 User-Agent: Thunderbird MIME-Version: 1.0 To: Nikita Nefedov CC: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] DateTime improvement From: keisial@gmail.com (=?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?=) On 10/12/12 16:18, Nikita Nefedov wrote: > So there had been at least two or three messages (subjects) about > DateTime object and everytime there was this problem - people tend to > take DateTime object as mutable object and it really is. > As long as we know, it's not so good - date is immutable by nature. I > don't want to write here why it's so, I will just throw this link: > http://www.ibm.com/developerworks/java/library/j-jtp02183/index.html > > I don't want to change any existing functionality, because some people > already use it, but I just wanted to point out that current DateTime > class is forcing people to think about it as mutable. > My main concerns are DateTime#add() and DateTime#sub(). The problem is > - they both change current object and return it. > I think we could add methods to DateTime like add() and sub(), let's > say plus() and minus(), but they would behave differently in the way > that they would return new DateTime objects and won't change current > object. That will make it even more inconsistent. You have add() and plus() but one changes the object and the other doesn't. If we were going to rewrite php or the DateTime class, it could be a good idea to make those methods (or its equivalents) not modify the object. But I don't think it'd be a win to do such thing now.