forked from atsushi444/iptv-epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.py
64 lines (43 loc) · 1.15 KB
/
tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#coding=utf-8
import time,datetime
TIME_ZONE=" +0800"
################ str="xx:xx"
'''
start="20180222044300 +0000" stop="20180222071500 +0000"
'''
##获取日期字符串20180222044300
def timeTostrOfsec(hs,d,flag=0):
tmp=d+datetime.timedelta(days=flag)
return timetofomat(tmp)+hs.replace(":","")+"00"
##获取结束时间
def stoptime(startime,duration,d):
duration/=60
list=startime.split(":")
hour=int(list[0])
min=int(list[1])
min+=duration
hour=hour+(min/60)
flag=hour
min%=60
hour%=24
hs="%02d:%02d"%(hour,min)
return timeTostrOfsec(hs,d,flag=flag/24)
##获取开始时间
def startime(hs,d):
return timeTostrOfsec(hs,d)
####获取星期几
def isToday():
today=datetime.datetime.now()
var=today.weekday()
return var
def timetofomat(day):
return day.strftime("%Y%m%d")
def getweeklist():
days=[]
monday=datetime.datetime.now()-datetime.timedelta(days=isToday())
for var in range(0,7):
nextday=monday+datetime.timedelta(days=var)
days.append(nextday)
return days
if __name__=="__main__":
print stoptime("23:00",4800,datetime.datetime.now())