Split out components into new files
This commit is contained in:
11
desktop-client/utils.py
Normal file
11
desktop-client/utils.py
Normal file
@@ -0,0 +1,11 @@
|
||||
def format_time_hms(ms: int) -> str:
|
||||
"""Format milliseconds as HH:MM:SS."""
|
||||
s = max(0, ms) // 1000
|
||||
return f"{s // 3600:02d}:{(s % 3600) // 60:02d}:{s % 60:02d}"
|
||||
|
||||
def format_time_short(ms: int) -> str:
|
||||
"""Format milliseconds as MM:SS or HH:MM:SS if >= 1 hour."""
|
||||
s = int(max(0, ms) // 1000)
|
||||
if s >= 3600:
|
||||
return f"{s // 3600:02d}:{(s % 3600) // 60:02d}:{s % 60:02d}"
|
||||
return f"{(s % 3600) // 60:02d}:{s % 60:02d}"
|
||||
Reference in New Issue
Block a user