[Tutor] time calc
Roel Schroeven
rschroev_nospam_ml at fastmail.fm
Mon Jun 21 08:16:25 EDT 2004
kevin parks wrote:
> What i want to do is append the duration to the end of this list by
> subtracting the start of the item from the start time of the next so
> that the first line would look like:
>
> 1 1 1 00:23 08:00
> 1 2 2 8:23 01:18
>
> etc.
>
> So the task is really two part : reading in a list of numbers and adding
> one more piece of data and (2) doing time (base 60) math. It is the time
> math part i simply can't get my head around. Anyone know if there is a
> module that does time math? or a method for doing this by hand?
I don't know if there is a module that makes this easier, but here is
how I would do it by hand.
You basically have times consisting of an hour part and a minute part. I
would convert this to minutes by multiplying the hours with 60 and
adding it to the minutes: m = 60*h + m
Then do your math on the minutes alone, and convert back to hours and
minutes when done:
h = m % 60
m = m / 60
--
"Codito ergo sum"
Roel Schroeven
More information about the Tutor
mailing list