formatted 'time' data in calculations

Scott David Daniels Scott.Daniels at Acm.Org
Wed Jan 7 17:51:22 EST 2009


John Machin wrote:
> On Jan 8, 6:23 am, Scott David Daniels <Scott.Dani... at Acm.Org> wrote:
>> ...some stuff perhaps too cranky...
>> Have you read the entire time module document?  If so, which functions
>> in that module take strings as arguments?.... then even more cranky stuff...
> 
> Indeed. Be not cranky at clueless bludgers and cargo-cultists ....

And since others are pointing you at datetime and othert places, I'll
just point out that I _did_, in fact, answer your question:
    (1) The answer to the oblique clue is strptime.
    (2) Only mktime takes a time_struct and returns a non-string.

     import time
     struct_time1 = time.strptime('14:11-01.07.09', '%H:%M-%m.%d.%y')
     struct_time2 = time.strptime('14:18-01.07.09', '%H:%M-%m.%d.%y')
     since_epoch1 = time.mktime(struct_time1)
     since_epoch2 = time.mktime(struct_time2)
     print int((since_epoch2 - since_epoch1) / 10)

Hmmmm.... where have I seen that number before?

A slightly less cranky kid because of the mollifying influence of
the ever-diplomatic John Machin.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list