[Zope3-dev] Dates and times

Shane Hathaway shane@zope.com
Wed, 20 Nov 2002 10:42:58 -0500


Chris Withers wrote:
> Marius Gedminas wrote:
> 
>>> Chris . o O ( whenToDo = time().addHours(4) )
>>
>>
>> That's what datetime is for.  time would not do the right thing at 11
>> pm, for example.
> 
> 
> Why?
> 
> time('23:00').addHours(4)==time('03:00')
> 
> What's wrong with that?

1) If you're in a timezone with daylight savings, sometimes 23:00 plus 4 
hours is 02:00, 02:30, 03:00, 03:30, or 04:00.  Sometimes it's even 
somewhere in between (like 02:45).  This is important in some applications.

2) It is just as easy to use a datetime(tz) and a timedelta to perform 
this calculation.  You may get a different answer depending on whether 
you use a datetime or a datetimetz. (I think--Guido, is this correct?)

History has proven that it is very hard to write a general date/time 
class.  Zope tried it and failed, because so many people's expectations 
were violated by correct time zone handling.  Sun tried to achieve it in 
Java, and came very close, but they still ended up confusing people.

I think the current plan for datetime is perfect.  If it violates 
someone's expectations, we just have to tell them to use datetime 
instead of datetimetz or vice-versa.  It avoids DWIM entirely.

Shane