Differents of two ZopeTime
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 ! Please help me ! Thanx for it ! -- Best regards, fowlertrainer mailto:fowlertrainer@anonym.hu
From: <fowlertrainer@anonym.hu>
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 !
Try (untested): sd=context.ZopeTime() se=context.ZopeTime() diff=context.ZopeTime(se-sd) print "diff=",diff.strftime('%X') This should give you a time difference in format: HH:MM:SS HTH Jonathan
Hello Small, Tuesday, March 23, 2004, 1:28:18 PM, you wrote: SBS> From: <fowlertrainer@anonym.hu>
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 !
SBS> Try (untested): SBS> sd=context.ZopeTime() SBS> se=context.ZopeTime() SBS> diff=context.ZopeTime(se-sd) SBS> print "diff=",diff.strftime('%X') SBS> This should give you a time difference in format: HH:MM:SS SBS> HTH Sorry, but it is not working... It shows 1 second only for every differents ! See: 2004/03/23 13:33:27.878 GMT+1 2004/03/23 13:33:43.180 GMT+1 0:0:15 302 01:00:00 !!!!!!! -- Best regards, fowlertrainer mailto:fowlertrainer@anonym.hu
From: <fowlertrainer@anonym.hu>
Hello Small,
Tuesday, March 23, 2004, 1:28:18 PM, you wrote:
SBS> From: <fowlertrainer@anonym.hu>
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 !
ok... how about: (also untested!) sd=context.float(ZopeTime()) se=context.float(ZopeTime()) diff = se-sd diff will then be the difference in time between sd and se, expressed in seconds (which you can then format as you please). Jonathan
fowlertrainer@anonym.hu wrote at 2004-3-23 12:39 +0100:
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 !
You should read the "DateTime" API (--> "DateTime/DateTime.html"). Watch out for the "timeTime()" method. -- Dieter
On Tuesday 23 March 2004 03:39 am, fowlertrainer@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
participants (4)
-
Alec Mitchell -
Dieter Maurer -
fowlertrainer@anonym.hu -
Small Business Services