Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Best API/abstraction? [Was: Time Pedantry] servers?)


On Thu, Apr 08, 2010, Del wrote:

> >So which language / library has a great abstraction for time and date 
> >stuff,
> >helping you deal with the intricacies of this craziness?
> 
> Zend Framework (PHP) -- Zend_Date.  The date handling functions in PHP are 
> pretty limited but this extension library of an extension library works 
> well.
> 
> Whatever library the Remember The Milk (www.rememberthemilk.com) folks use 
> is pretty good.  I can type in "second friday after the third tuesday in 
> november at 4pm" and it gets that, and sends me the reminder notice at the 
> correct time even if I tell it I've changed my time zone to "Chatham 
> Islands Daylight Savings Time" in the mean while.  It also understands that 
> "repeat every three weeks" means 21 days after the event was first 
> scheduled but "repeat after three weeks" means 21 days after I actually got 
> around to doing it (after postponing it several times).

Right, but that's just for parsing dates. But does your code, which uses
timestamps for calculation, get "one day later" correct when DST changeovers
occur? When leap seconds occur?

Most users/developers only see date parsing and storage as the only issues.
There's also date manipulation (eg "now plus a day"), date comparison, etc.

Most developers never have to care about things such as the occasional
leap seconds. But this means "next day" does not necessarily mean "current
unix timestamp + 86400 seconds" and some environments I've been in matter.
(Say you're billing thousands of dollars every -second- per client 
and your clients are happy to sue if you fuck up...)



Adrian