Skip to content

Instantly share code, notes, and snippets.

@RRRoger
Created September 21, 2018 03:12
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 RRRoger/3898985b6ec0d14d236feb73ca8a5a90 to your computer and use it in GitHub Desktop.
Save RRRoger/3898985b6ec0d14d236feb73ca8a5a90 to your computer and use it in GitHub Desktop.
min2millisec
def min2millisec(t):
"""
将`03:36`转化成毫秒
:param t: min string like '00:43'
:return: millisec int
"""
if not t:
return t
tim = t.split(":")[::-1]
depth = 0
rel = 60
res = 0
for s in tim:
res += float(s) * (rel ** depth)
depth += 1
return res * 1000
@RRRoger
Copy link
Author

RRRoger commented Nov 13, 2018

  • 只能支持到小时;
  • 1:20:30.123 格式也支持哦;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment