Spaces:
Runtime error
Runtime error
Update bot/core/uptime.py
Browse files- 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"
|