上传修改的预统计接口的关键字和case,以及自定义库GetTimeLibrary
This commit is contained in:
57
04-CustomLibrary/ExtensionPackages/GetTimeLibrary/GetTime.py
Normal file
57
04-CustomLibrary/ExtensionPackages/GetTimeLibrary/GetTime.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#coding=utf-8
|
||||
import datetime
|
||||
import time
|
||||
import string
|
||||
class GetTime():
|
||||
def __init__(self):
|
||||
pass
|
||||
def time1(self,t):
|
||||
if t=="m":
|
||||
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
|
||||
if time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))[-4] >= "5":
|
||||
time2=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))[0:-4]+"5:00"
|
||||
return time2
|
||||
else:
|
||||
time2=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))[0:-4] + "0:00"
|
||||
return time2
|
||||
elif t=="s":
|
||||
if time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))[-2] >= "3":
|
||||
time2=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))[0:-2]+"30"
|
||||
return time2
|
||||
else:
|
||||
time2=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))[0:-2] + "00"
|
||||
return time2
|
||||
elif t=="h":
|
||||
time2=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))[0:-7]+":00:00"
|
||||
startTime = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
|
||||
startTime2 = (startTime + datetime.timedelta(hours=-1)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
return startTime2
|
||||
elif t=="5m":
|
||||
time2 = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
|
||||
print(time2)
|
||||
startTime = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
|
||||
startTime2 = (startTime + datetime.timedelta(minutes=-5)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
if startTime2[-4]>="5":
|
||||
time3 = startTime2[0:-4] + "5:00"
|
||||
print(time3)
|
||||
else:
|
||||
time3 = startTime2[0:-4] + "0:00"
|
||||
print(time3)
|
||||
return time3
|
||||
elif t== "30s":
|
||||
time2 = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
|
||||
print(time2)
|
||||
startTime = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
|
||||
startTime2 = (startTime + datetime.timedelta(seconds=-30)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
if startTime2[-2] >= "3":
|
||||
time3 = startTime2[0:-2]+"30"
|
||||
print(time3)
|
||||
return time3
|
||||
else:
|
||||
time3 = startTime2[0:-2]+"00"
|
||||
print(time3)
|
||||
return time3
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user