[Zope] Differents of two ZopeTime

Alec Mitchell apm13 at columbia.edu
Tue Mar 23 18:10:32 EST 2004


On Tuesday 23 March 2004 03:39 am, fowlertrainer at anonym.hu wrote:
> Hello zope,
>
>   I want to measure the time of process in Zope.
>
>   sd=context.ZopeTime()
>   ...
>   se=context.ZopeTime()
>   d=se-sd
>   print str(DateTime(str(sd))
>   print str(DateTime(str(se))
>
>   it is working, so it is show the two datetimes.
>
>   But how to I show the different of the times ?
>   print str(DateTime(str(d)) is not working good !

The issue is that the difference between two dates (d) is not itself a date, 
it is an interval.  Python expresses this interval (d) as a floating point 
number representing the number of days between the two dates.  It is trivial 
to convert this to hours, minutes, seconds, fortnights, or whatever you might 
need.  In addition in the python 'datetime' (not Zope's DateTime) module 
there is a timedelta class which extracts the days, seconds, microseconds for 
you.

Alec Mitchell



More information about the Zope mailing list