(seconds: int)
| 3 | # (c) TechifyBots |
| 4 | |
| 5 | def 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 |
no outgoing calls
no test coverage detected