Home

On Mon, 10 Sep 2007 07:57:58 -0700, cjt22@bath.ac.uk declaimed the
following in comp.lang.python:

> >from time import *
> >startPoint = strptime(step.sTime, "%H:%S:%M")
> >finishPoint = strptime(step.fTime, "%H:%S:%M")
>
> >duration = mktime(startPoint) - mktime(finishPoint)
>
Ignoring the mktime() error, shouldn't those be reversed -- end
times are larger than start times...

> but it generates the error
>
> >OverflowError: mktime argument out of range
>

I suspect you will need to supply a full date... mktime() wants
calendar date/time values, not some HMS value that is relative to an
arbitrary zero. That is, if your data is in the form "9h 5m, 20s from
start of effort" you need to supply a dummy day representing "start of
effort" (midnight probably)

Maybe look at the documentation for the datetime module -- in
particular timedelta()

>>> from datetime import timedelta
>>> pStart = timedelta(hours=9, minutes=5, seconds=20)
>>> pEnd = timedelta(hours=13, minutes=21, seconds=5)
>>> dur = pEnd - pStart
>>> print dur.days, dur.seconds, dur.microseconds
0 15345 0
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/

previous
next

Re: Needless copying in iterations?
Re: Will Python 3.0 remove the global interpreter lock (GIL)
Re: How do we recognize veterans as veterans?
Re: regexp search on infinite string?
Re: Check for dict key existence, and modify it in one step.
Fundacja Sloneczko
Krwinka
Rodzic Po Ludzku
Mam Marzenie
Podaruj Zycie