understanding commited on
Commit
01792e5
·
verified ·
1 Parent(s): 904accf

Update bot/core/uptime.py

Browse files
Files changed (1) hide show
  1. bot/core/uptime.py +17 -1
bot/core/uptime.py CHANGED
@@ -4,4 +4,20 @@ import time
4
  START_TS = time.time()
5
 
6
  def uptime_seconds() -> int:
7
- return int(time.time() - START_TS)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  START_TS = time.time()
5
 
6
  def uptime_seconds() -> int:
7
+ return int(time.time() - START_TS)
8
+
9
+ def uptime_text() -> str:
10
+ s = uptime_seconds()
11
+ if s < 0:
12
+ s = 0
13
+ m, s = divmod(s, 60)
14
+ h, m = divmod(m, 60)
15
+ d, h = divmod(h, 24)
16
+
17
+ if d:
18
+ return f"{d}d {h}h {m}m"
19
+ if h:
20
+ return f"{h}h {m}m"
21
+ if m:
22
+ return f"{m}m {s}s"
23
+ return f"{s}s"