Re: [Tutor] Difference in minutes between two time stamps

2009-03-03 Thread Tim Michelsen

  import datetime

s = '09:35:23'
datetime.datetime.strptime(s, '%H:%M:%S')

datetime.datetime(1900, 1, 1, 9, 35, 23)

Can you figure out how to proceed from there?

In case she doesn't know:

import datetime as dt
start=09:35:23
end=10:23:00

start_dt = dt.datetime.strptime(start, '%H:%M:%S')

end_dt = dt.datetime.strptime(end, '%H:%M:%S')

diff.seconds/60

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Difference in minutes between two time stamps

2009-03-03 Thread Tim Michelsen



  import datetime

s = '09:35:23'
datetime.datetime.strptime(s, '%H:%M:%S')

datetime.datetime(1900, 1, 1, 9, 35, 23)

Can you figure out how to proceed from there?

In case she doesn't know:

import datetime as dt
start=09:35:23
end=10:23:00

start_dt = dt.datetime.strptime(start, '%H:%M:%S')

end_dt = dt.datetime.strptime(end, '%H:%M:%S')


I forgot to paste in between:
diff = (end_dt - start_dt)


diff.seconds/60


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Difference in minutes between two time stamps

2009-03-02 Thread Judith Flores

Hello,

   I can't seem to figure out the syntax to calculate the difference in minutes 
between two time stamps. I already read the documentation about datetime and 
time modules, but I was unable to implement the code.

My code will be fed with two timestamps (as styrings):

start=09:35:23
end=10:23:00

Could someone guide me on how to calculate the difference in minutes 
between both stamps?

Your help is very much appreciated.

Thank you,

Judith


  
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Difference in minutes between two time stamps

2009-03-02 Thread John Fouhy
2009/3/3 Judith Flores jur...@yahoo.com:

 Hello,

   I can't seem to figure out the syntax to calculate the difference in 
 minutes between two time stamps. I already read the documentation about 
 datetime and time modules, but I was unable to implement the code.

 My code will be fed with two timestamps (as styrings):

 start=09:35:23
 end=10:23:00

    Could someone guide me on how to calculate the difference in minutes 
 between both stamps?

You want to use the datetime.datetime.strptime() function to parse the
timestamps.  Although you will probably need to look at the time
module to get the different codes -- the documentation isn't superbly
organised in this area, I feel.

Anyway, as a start:

 import datetime
 s = '09:35:23'
 datetime.datetime.strptime(s, '%H:%M:%S')
datetime.datetime(1900, 1, 1, 9, 35, 23)

Can you figure out how to proceed from there?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor