Optimized some code

This commit is contained in:
Choco
2024-06-26 07:42:37 +08:00
parent ce14d6dc9e
commit 7ef2700730
10 changed files with 165 additions and 166 deletions

View File

@@ -83,11 +83,11 @@ def time(millis:int) -> str:
minutes=(millis/(1000*60))%60
hours=(millis/(1000*60*60))%24
if hours > 1:
return "%02d:%02d:%02d" % (hours, minutes, seconds)
return "%d:%02d:%02d" % (hours, minutes, seconds)
else:
return "%02d:%02d" % (minutes, seconds)
def formatTime(number:str) -> Optional[int]:
def format_time(number:str) -> int:
try:
try:
num = strptime(number, '%M:%S')
@@ -97,7 +97,7 @@ def formatTime(number:str) -> Optional[int]:
except ValueError:
num = strptime(number, '%H:%M:%S')
except:
return None
return 0
return (int(num.tm_hour) * 3600 + int(num.tm_min) * 60 + int(num.tm_sec)) * 1000