Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64246 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40904 invoked from network); 11 Dec 2012 01:51:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2012 01:51:18 -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.123 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.123 smtp123.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.123] ([67.192.241.123:54907] helo=smtp123.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/A3-16251-59196C05 for ; Mon, 10 Dec 2012 20:51:17 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp12.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id D621B3C0374; Mon, 10 Dec 2012 20:51:14 -0500 (EST) X-Virus-Scanned: OK Received: by smtp12.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 50D1D3C035D; Mon, 10 Dec 2012 20:51:14 -0500 (EST) Message-ID: <50C69191.5020201@sugarcrm.com> Date: Mon, 10 Dec 2012 17:51:13 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 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: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > 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 Date is immutable, but there's no reason why date object should be able to represent only one date. Reference to Java is not exactly applicable here, as many problems existing in Java (thread safety, long-living object references, etc.) do not exist in PHP. > 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. It does not - if you don't need it mutable, don't use modify() or override modify() with method that would clone the object and return modified clone. This can easily be done in userspace if you require an immutable object, which most of the users actually do not. > Also, there's methods compareTo, createFromTimestamp and createFromDay, it > could be another proposal. I think we are very often create DateTime > objects just from timestamp or year-month-day. So we could introduce this > methods that could not rely on timelib's parsing, and instead just take > numbers directly. Timestamp doesn't need any timelib parsing AFAIK, but YMD certainly does - you need to calculate the actual timestamp according to current timezone, etc. > And I think DateTime lack comparing method. For now I can compare DateTime > objects only by getting their timestamps, but I though that the idea of DateTime objects can be compared directly, why do you think you can compare only timestamps? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227