llm-py-web/server/tid.py

13 lines
305 B
Python

# i stole this from david
import time
B32_CHARSET = "234567abcdefghijklmnopqrstuvwxyz"
def tid_now():
micros, nanos = divmod(int(time.time() * 1_000_000_000), 1000)
clkid = nanos
tid_int = (micros << 10) | clkid
return "".join(
B32_CHARSET[(tid_int >> (60 - (i * 5))) & 31] for i in range(13)
)