MCPcopy Create free account
hub / github.com/TechifyBots/File-Stream-Bot / get_readable_time

Function get_readable_time

biisal/utils/time_format.py:5–26  ·  view source on GitHub ↗
(seconds: int)

Source from the content-addressed store, hash-verified

3# (c) TechifyBots
4
5def get_readable_time(seconds: int) -> str:
6 count = 0
7 readable_time = ""
8 time_list = []
9 time_suffix_list = ["s", "m", "h", " days"]
10 while count < 4:
11 count += 1
12 if count < 3:
13 remainder, result = divmod(seconds, 60)
14 else:
15 remainder, result = divmod(seconds, 24)
16 if seconds == 0 and remainder == 0:
17 break
18 time_list.append(int(result))
19 seconds = int(remainder)
20 for x in range(len(time_list)):
21 time_list[x] = str(time_list[x]) + time_suffix_list[x]
22 if len(time_list) == 4:
23 readable_time += time_list.pop() + ", "
24 time_list.reverse()
25 readable_time += ": ".join(time_list)
26 return readable_time

Callers 1

root_route_handlerFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected