1 from Components.NimManager import nimmanager
2 from time import localtime
4 class TimerSanityCheck:
5 def __init__(self, timerlist, newtimer):
6 self.timerlist = timerlist
7 self.newtimer = newtimer
11 self.simultimer = [ self.newtimer ]
12 for timer in self.timerlist:
13 if self.isSimultaneous(timer, self.newtimer):
14 self.simultimer.append(timer)
16 if len(self.simultimer) > 1:
17 return self.checkRecordable(self.simultimer)
21 def getSimulTimerList(self):
22 return self.simultimer
24 def isSimultaneous(self, timer1, timer2):
25 # both timers are repeated
26 if (timer1.repeated & timer2.repeated):
27 return self.timeEquals(timer1, timer2)
29 # one timer is repeated
30 if not timer1.repeated:
36 dow2 = (localtime(timer2.begin).tm_wday - 1) % 7
38 if timer1.repeated & (2 ** dow2):
39 return self.timeEquals(timer1, timer2)
41 if (timer1.begin <= timer2.begin < timer1.end) or (timer2.begin <= timer1.begin < timer2.end):
46 def timeEquals(self, timer1, timer2):
47 ltb1 = localtime(timer1.begin)
48 ltb2 = localtime(timer2.begin)
50 begin1 = ltb1.tm_hour * 3600 + ltb1.tm_min * 60 + ltb1.tm_sec
51 begin2 = ltb2.tm_hour * 3600 + ltb2.tm_min * 60 + ltb2.tm_sec
53 end1 = begin1 + timer1.end - timer1.begin
54 end2 = begin2 + timer2.end - timer2.begin
56 return (begin1 <= begin2 < end1) or (begin2 <= begin1 < end2)
58 def checkRecordable(self, timerlist):