Re: Date methods simplified

From: Date: Thu, 23 May 2002 08:08:16 +0000
Subject: Re: Date methods simplified
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6354@lists.php.net to get a copy of this message
Alan Knowles wrote:
there looks like alot overlap in the two classes and php4/pear.. http://docs.akbkhome.com/pear/classes/Date_Calc.html and this. http://docs.akbkhome.com/pearcvs/classes/Date.html the tempation with the date class is to break it up a little -- core stuff (Date?) simple get/set + getUnixTime(), format(...); -- more complex stuff.. (Date_Calc extends Date) = a merge of Date_Calc and this one... isWeekday..., getJulianDate(), before, after......
If you look carefully, Date makes use of Date_Calc quite extensivly. Date_Calc was already in existance, but only operated on dates, not times. Plus Date_Calc is all static methods. If Date_Calc had not existed, then all the code would have just been in the Date class, but since Date_Calc was there and already installed by default with PEAR I figured I'd just use its methods where I could.
without documentation... - read this in some source, without knowing how the date class works... $date->getTime() returns ? a) "10:30" b) 103434034040 it looks like it should return a) or similar, however it returns b)... - the utime... this ones a prime candidate for changing ...
Well, without documentation we'd never know what anything returned ;) and the inline API documentation makes it very clear what getTime() returns. Just as you rarely print the output of time(), its likely that most output from the Date class will be through the format() method, which emulates strftime(). b -- 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

« previous php.pear.dev (#6354) next »