fix typo
[enigma2.git] / lib / python / Components / TimerSanityCheck.py
index a5b81ffccda934add000e4ceef1fa4f30871a728..a6af141270d65c61047b96ef456039cc36ab2ef6 100644 (file)
@@ -6,22 +6,26 @@ class TimerSanityCheck:
        def __init__(self, timerlist, newtimer):
                self.timerlist = timerlist
                self.newtimer = newtimer
-               
+               self.simultimer = []
+                               
        def check(self):
-               simultimer = [ self.newtimer ]
+               self.simultimer = [ self.newtimer ]
                for timer in self.timerlist:
                        if self.isSimultaneous(timer, self.newtimer):
-                               simultimer.append(timer)
-                               
-               if len(simultimer) > 1:
-                       return self.checkRecordable(simultimer)
+                               self.simultimer.append(timer)
+               
+               if len(self.simultimer) > 1:
+                       return self.checkRecordable(self.simultimer)
                
                return True
+
+       def getSimulTimerList(self):
+               return self.simultimer
        
        def isSimultaneous(self, timer1, timer2):
                # both timers are repeated
                if (timer1.repeated & timer2.repeated):
-                       return True
+                       return self.timeEquals(timer1, timer2)
 
                # one timer is repeated
                if not timer1.repeated:
@@ -33,12 +37,24 @@ class TimerSanityCheck:
                        dow2 = (localtime(timer2.begin).tm_wday - 1) % 7
                        
                        if timer1.repeated & (2 ** dow2):
-                               return True
+                               return self.timeEquals(timer1, timer2)
                else:
-                       if (timer1.begin < timer2.begin < timer1.end) or (timer2.begin < timer1.begin < timer2.end):
+                       if (timer1.begin <= timer2.begin < timer1.end) or (timer2.begin <= timer1.begin < timer2.end):
                                return True
 
                return False
+
+       def timeEquals(self, timer1, timer2):
+               ltb1 = localtime(timer1.begin)
+               ltb2 = localtime(timer2.begin)
+                               
+               begin1 = ltb1.tm_hour * 3600 + ltb1.tm_min * 60 + ltb1.tm_sec
+               begin2 = ltb2.tm_hour * 3600 + ltb2.tm_min * 60 + ltb2.tm_sec
+               
+               end1 = begin1 + timer1.end - timer1.begin
+               end2 = begin2 + timer2.end - timer2.begin
+               
+               return (begin1 <= begin2 < end1) or (begin2 <= begin1 < end2)
        
        def checkRecordable(self, timerlist):
                # TODO: Add code here