File size: 425 Bytes
5937486
 
 
 
 
 
01792e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# PATH: bot/core/uptime.py
import time

START_TS = time.time()

def uptime_seconds() -> int:
    return int(time.time() - START_TS)

def uptime_text() -> str:
    s = uptime_seconds()
    if s < 0:
        s = 0
    m, s = divmod(s, 60)
    h, m = divmod(m, 60)
    d, h = divmod(h, 24)

    if d:
        return f"{d}d {h}h {m}m"
    if h:
        return f"{h}h {m}m"
    if m:
        return f"{m}m {s}s"
    return f"{s}s"