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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to