1 from Components.config import config
2 from Components.NimManager import nimmanager
3 from time import localtime
5 class TimerSanityCheck:
6 def __init__(self, timerlist, newtimer):
7 self.timerlist = timerlist
8 self.newtimer = newtimer
12 self.simultimer = [ self.newtimer ]
13 for timer in self.timerlist:
14 if self.isSimultaneous(timer, self.newtimer):
15 self.simultimer.append(timer)
17 if len(self.simultimer) > 1:
18 return self.checkRecordable(self.simultimer)
22 def getSimulTimerList(self):
23 return self.simultimer
25 def isSimultaneous(self, timer1, timer2):
26 # both timers are repeated
27 if (timer1.repeated & timer2.repeated):
28 return self.timeEquals(timer1, timer2)
30 # one timer is repeated
31 if not timer1.repeated:
37 dow2 = (localtime(timer2.begin).tm_wday - 1) % 7
39 if timer1.repeated & (2 ** dow2):
40 return self.timeEquals(timer1, timer2)
42 if (timer1.begin <= timer2.begin < timer1.end) or (timer2.begin <= timer1.begin < timer2.end):
47 def timeEquals(self, timer1, timer2):
48 ltb1 = localtime(timer1.begin)
49 ltb2 = localtime(timer2.begin)
51 begin1 = ltb1.tm_hour * 3600 + ltb1.tm_min * 60 + ltb1.tm_sec
52 begin2 = ltb2.tm_hour * 3600 + ltb2.tm_min * 60 + ltb2.tm_sec
54 end1 = begin1 + timer1.end - timer1.begin
55 end2 = begin2 + timer2.end - timer2.begin
57 return (begin1 <= begin2 < end1) or (begin2 <= begin1 < end2)
59 def checkRecordable(self, timerlist):