Guest User

Untitled

a guest
Apr 21st, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. import re
  2.  
  3. def convert_time_to_sec(time):
  4. # validate format
  5. if time == '':
  6. time = '00:00:00'
  7.  
  8. time_to_array = re.split(':', time)
  9.  
  10. hours = float(time_to_array[0]) * 60. * 60.
  11. minutes = float(time_to_array[1]) * 60.
  12. seconds = float(time_to_array[2])
  13.  
  14. total_time = hours + minutes + seconds
  15.  
  16. return total_time
Advertisement
Add Comment
Please, Sign In to add comment