Re: Date methods simplified
| From: | Baba Buehler | Date: | Thu, 23 May 2002 07:34:50 +0000 |
| Subject: | Re: Date methods simplified | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-6351@lists.php.net to get a copy of this message | ||
Alan Knowles wrote:
Ok, after a bit more examination... getTime would make more sense as getUtime or getUnixTime ...getTime() was named that because that's what the Java java.util.Date method is called that returns the time in unixtime format. also time() is the C/PHP function used... either way... I mostly included getTime() as a convienence so you wouldn't have to write getDate(DATE_FORMAT_UNIXTIME) every time you needed to pass seconds into some other function.
the getDay,getSeconds,getMonth all seem a bit of a waste of space - i guess they come from the java port, however in PHP unless the seconds where private, $this->_seconds etc., or when php5 adds private var, the tempation would be to access these directly???get get*() accessor methods are there to promote "good" OO development. and if, in some mythical future, Whizbang-Date-Time-XP<tm> gets added to PHP, the Date class could be rewritten for that, keeping the API the same. or if someone subclassed Date to work on MCAL dates or something, other code could still use it through the same API. anyway, you're right, the data fields should probably be private... can't wait for "real" private vars and all the other goodies coming with PHP5 :) later, baba -- Baba Z Buehler <baba@BabaZ.com> http://BabaZ.com/ PGP KeyID: 0xA88A6D4C "Those who are willing to sacrifice freedom for security deserve neither." -Benjamin Franklin