51 lines
1.4 KiB
Python
Raw Normal View History

2025-04-10 17:31:33 +08:00
# coding=utf-8
import time
def get_time_stamp():
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)
return time_stamp
def get_time_stamp_ms():
t = time.time()
return (int(round(t * 1000))) #毫秒级时间戳
def get_time_stamp_us():
t = time.time()
return (int(round(t * 1000000))) #微秒级时间戳
def time_week_ver():
ct = time.time()
#local_time = time.localtime(ct)
local_time = time.localtime(time.mktime((2020, 1, 7, 0, 0, 0, 0, 0, 0)))
#print(time.strftime("%U", local_time))
#print(int(time.strftime("%U", local_time))*2)
s_time = time.mktime((2019, 6, 3, 0, 0, 0, 0, 0, 0))
start_time = time.localtime(s_time)
start_day=int(time.strftime("%j", start_time))
start_year=int(time.strftime("%Y", start_time))
start_week=int(time.strftime("%U", start_time))
#print(start_day)
#print(start_year)
#print(start_week)
local_day=int(time.strftime("%j", local_time))
local_year=int(time.strftime("%Y", local_time))
local_week=int(time.strftime("%U", local_time))
#print(local_day)
#print(local_year)
#print(local_week)
base_version = ((local_year-start_year)*52+(local_week-start_week))*2
#print(base_version)
w=int(time.strftime("%w",local_time))
if w > 3:
add_ver=2
print(" week 4")
else:
add_ver=1
print("week 2")
ver = base_version+add_ver
print(ver)