| 1234567891011121314151617181920212223242526272829303132 |
- def get_readable_time(seconds: int) -> str:
- count = 0
- ping_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 i in range(len(time_list)):
- time_list[i] = str(time_list[i]) + time_suffix_list[i]
- if len(time_list) == 4:
- ping_time += time_list.pop() + ", "
- time_list.reverse()
- ping_time += ":".join(time_list)
- return ping_time
- # Convert seconds to mm:ss
- async def convert_seconds_to_minutes(seconds: int):
- seconds = int(seconds)
- seconds = seconds % (24 * 3600)
- seconds %= 3600
- minutes = seconds // 60
- seconds %= 60
- return "%02d:%02d" % (minutes, seconds)
|