formatted 'time' data in calculations

Scott David Daniels Scott.Daniels at Acm.Org
Wed Jan 7 20:23:32 CET 2009

Ross wrote:
> There seems to be no shortage of information around on how to use the 
> time module, for example to use time.ctime() and push it into strftime 
> and get something nice out the other side, but I haven't found anything 
> helpful in going the other way.

As to a paucity of conversion formatting, there is no magic way to take
everyone's way of putting date and time information in text and convert
it to unambiguous format, in part because there are too many different
and contradictory formats.  When I write dates, I know what I intended;
when I read dates, I guess what the author intended.

Have you read the entire time module document?  If so, which functions
in that module take strings as arguments?

> That is, given some formatted text describing times - is there something 
> that makes it easy to calculate time differences, or do I have to index 
> my way through the string pulling out characters, converting to integers 
> etc...
> Data is formatted:
>    t1 = 09:12:10
>    t2 = 11:22:14
> I want to calculate tdiff = t2-t1

Do you do any work yourself?  Show us your attempts.  This looks like
a trivial exercise.  It seems that for less than four times the effort
of asking your question you might have found the answer.

Perhaps I am being too cranky this morning.
--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-list mailing list