[ABE.pm] time processing
Ted Fiedler
fiedlert at gmail.com
Mon Nov 19 11:54:31 PST 2007
>
>
>
> The conversion to seconds is simple -- there are 60 seconds in a
> minute, and 60*60=3600 seconds in an hour. So you just multiply it
> out, and divide by the distance to get the pace.
>
> The conversion back to minutes and seconds is maybe a bit trickier.
> If you divide the total seconds by 60, you get minutes. But we don't
> care about the fractional part, so I used int() to trim it off. The
> number of seconds in that minute is the remainder when we divide the
> total seconds by 60. That's what the % operator does. (For some
> reason people always seem to forget about the % operator. It's very
> useful.)
>
> The formatting is simple with printf. %02d formats the argument as a
> 2-digit number with leading 0's.
>
> Hope this helps.
>
Yes. the modulus is what I was missing and what led me down the path of
external modules.
Thanks guys!
Ted
--
If you mess with a thing long enough, it'll break.
-- Schmidt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/abe-pm/attachments/20071119/ee106e52/attachment-0001.html
More information about the ABE-pm
mailing list