def current_timestamp(timestamp, period):
time_list = list(time.gmtime())
period = period.lower()
if period == "day":
time_list[3:] = [0] * 6
elif period == "month":
time_list[2:] = [1] + [0] * 6
elif period == "week":
time_list[2] -= time_list[6]
time_list[3:] = [0] * 6
elif period == "year":
time_list[1:] = [1, 1] + [0] * 6
else:
return None
return time.gmtime(calendar.timegm(time_list))
评论列表
文章目录