[Zope3-dev] Dates and times

Guido van Rossum guido@python.org
Fri, 15 Nov 2002 12:10:26 -0500


> > What's your use case for adding a timedelta to a time?
> 
> The following use case is a mood point, but I find it useful:
> 
> When I have a meeting, I often say that I meet at 4:30 pm for an
> hour, not I meet from 4:30 pm to 5:30 pm. Therefore I can store the
> duration of a meeting in a time delta and to calculate the end of a
> meeting I just add it to the start time. Others might claim that
> storing the beginning and the end is better...

If you look carefully, the meeting starting point is a datetime, not
just a time.  Adding an hour to a datetime is of course supported.
The problem with adding an hour to a time is that if it goes past
24:00, there's no way to express the "tomorrow" carry bit.

> Also, databases (especially PostGreSQL, which has an awesome
> datetime support) support the notion of time and timedelta
> arithmatic.

But is it used (other than for marketing)?

I'd like to call YAGNI on time arithmetic unless someone comes up with
a *real* example -- which should also explain the desirable semantics
of overflow.

--Guido van Rossum (home page: http://www.python.org/~guido/)