forked from EverythingSuckz/TG-FileStreamBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_format.py
More file actions
22 lines (22 loc) · 727 Bytes
/
Copy pathtime_format.py
File metadata and controls
22 lines (22 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def get_readable_time(seconds: int) -> str:
count = 0
readable_time = ""
time_list = []
time_suffix_list = ["s", "m", "h", " days"]
while count < 4:
count += 1
if count < 3:
remainder, result = divmod(seconds, 60)
else:
remainder, result = divmod(seconds, 24)
if seconds == 0 and remainder == 0:
break
time_list.append(int(result))
seconds = int(remainder)
for x in range(len(time_list)):
time_list[x] = str(time_list[x]) + time_suffix_list[x]
if len(time_list) == 4:
readable_time += time_list.pop() + ", "
time_list.reverse()
readable_time += ": ".join(time_list)
return readable_time