Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
Create timefunc.py
Browse files Browse the repository at this point in the history
  • Loading branch information
avipatilpro authored Sep 17, 2020
1 parent 55f6b30 commit a0b85f5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions userbot/modules/timefunc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import time

uptimebot = time.time()


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 x in range(len(time_list)):
time_list[x] = str(time_list[x]) + time_suffix_list[x]
if len(time_list) == 4:
ping_time += time_list.pop() + ", "

time_list.reverse()
ping_time += ":".join(time_list)

return ping_time

1 comment on commit a0b85f5

@avipatilpro
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimeFunc.py

Please sign in to comment.