Skip to content

Instantly share code, notes, and snippets.

@korakot
Created January 6, 2021 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korakot/40ba0894470d297ea1811760f49b65a3 to your computer and use it in GitHub Desktop.
Save korakot/40ba0894470d297ea1811760f49b65a3 to your computer and use it in GitHub Desktop.
Convert time_string to seconds
def to_sec(tstr):
""" 1:01:01 -> 3661 """
t = 0
for p in tstr.split(':'):
t *= 60
t += int(p)
return t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment