wd-rating/utils/time_serial_num_utils.py

13 lines
497 B
Python
Raw Normal View History

2023-10-07 15:24:29 +08:00
import time
def create_time_serial_num(prefix: str = "", suffix: str = ""):
ct = time.time()
local_time = time.localtime(ct)
data_head = time.strftime("%Y-%m-%d %H:%M:%S", local_time)
data_secs = (ct - int(ct)) * 1000
time_stamp = "%s.%03d" % (data_head, data_secs)
stamp = ("".join(time_stamp.split()[0].split("-")) + "".join(time_stamp.split()[1].split(":"))).replace('.', '')
time_serial_num = "{}{}{}".format(prefix, stamp[2:], suffix)
return time_serial_num