mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2025-01-02 06:50:12 +00:00
add days to seconds string converter
This commit is contained in:
parent
7e2cd6acd3
commit
7082718c14
@ -35,24 +35,27 @@ class DurationConverter:
|
|||||||
return duration_sec
|
return duration_sec
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_str(duration_sec):
|
def get_str(seconds):
|
||||||
"""takes duration in sec and returns clean string"""
|
"""takes duration in sec and returns clean string"""
|
||||||
if not duration_sec:
|
if not seconds:
|
||||||
# failed to extract
|
# failed to extract
|
||||||
return "NA"
|
return "NA"
|
||||||
|
|
||||||
hours = int(duration_sec // 3600)
|
days = int(seconds // (24 * 3600))
|
||||||
minutes = int((duration_sec - (hours * 3600)) // 60)
|
hours = int((seconds % (24 * 3600)) // 3600)
|
||||||
secs = int(duration_sec - (hours * 3600) - (minutes * 60))
|
minutes = int((seconds % 3600) // 60)
|
||||||
|
seconds = int(seconds % 60)
|
||||||
|
|
||||||
duration_str = str()
|
duration_str = str()
|
||||||
|
if days:
|
||||||
|
duration_str = f"{days}d "
|
||||||
if hours:
|
if hours:
|
||||||
duration_str = str(hours).zfill(2) + ":"
|
duration_str = duration_str + str(hours).zfill(2) + ":"
|
||||||
if minutes:
|
if minutes:
|
||||||
duration_str = duration_str + str(minutes).zfill(2) + ":"
|
duration_str = duration_str + str(minutes).zfill(2) + ":"
|
||||||
else:
|
else:
|
||||||
duration_str = duration_str + "00:"
|
duration_str = duration_str + "00:"
|
||||||
duration_str = duration_str + str(secs).zfill(2)
|
duration_str = duration_str + str(seconds).zfill(2)
|
||||||
return duration_str
|
return duration_str
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user