Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
avipatilpro authored Jun 5, 2021
1 parent 3ed6c02 commit 5bfa832
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions WebStreamer/utils/time_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Bot Uptime

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

0 comments on commit 5bfa832

Please sign in to comment.