[Zope3-dev] Dates and times

Steve Alexander steve@cat-box.net
Fri, 15 Nov 2002 20:01:46 +0000


Guido van Rossum wrote:

> >I think that a time object is good, even though it will not need
> >much arithmatic. I think time +/- timedelta and time-time=timedelta
> >is enough.  When I was writing Proiektor back in the days, I played
> >a lot with that for the reasons Barry listed. If you have for
> >example a meeting every Monday (excluding holidays) at 4:30 pm, then
> >I usually coded this by defining a time 4:30 pm with some logic
> >describing the repeating Mondays.
>
>
> What's your use case for adding a timedelta to a time?

I like making houmous.

Generally on friday evenings, I soak the chickpeas (garbanzos, to 
Americans).
On Saturday morning I can boil them. I don't always do this on fridays 
and saturdays, though. Sometimes I do it on different days.

I need to boil them for three hours, changing the water every hour.

My schedule for attending to this is to start at 10am, then change the 
water one hour later, and one additional hour after that. One further 
hour later, the chickpeas are boiled.

I want to represent this schedule as a set of times in a day. The 
algorithm for coming up with the appointments in a day starts with me 
giving the time I want to start it.

   Start time                         10am
   Time of first change of water      10am + 1 hour  = 11am
   Time of second change of water     10am + 2 hours = 12pm
   ... and so forth

When I want to apply this schedule of related appointments to a 
particular day (that is, a datetime).


Another more common example is planning a workshop. The activities in a 
workshop are of a known length. You sometimes need to plan the days of a 
workshop, and then choose the dates later.

--
Steve Alexander