[Zope3-dev] Dates and times

Tim Peters tim@zope.com
Fri, 15 Nov 2002 14:34:32 -0500


[Steve Alexander, makes houmous for us]
> ...
>    Start time                         10am

Then you would attach 10am (a time) to a datetime object (representing the
day on which you begin), yielding a datetime representing your starting
time.

>    Time of first change of water      10am + 1 hour  = 11am

This "1 hour" is an interval, not "a time".  You would add a 1-hour
timedelta to the datetime object from the first step, yielding a datetime
object representing time-of-first-change-of-water.  If you happened to begin
at 11:46pm, no problem -- it would shift to the next day.

>    Time of second change of water     10am + 2 hours = 12pm

"2 hours" here is also an interval.

>    ... and so forth

Ditto.  You need arithmetic on datetime objects here, not on time objects.

> 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.

I'd plan for a specific day for the sake of concreteness, then add whatever
day timedelta turned out to be appropriate.