summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-06-19 13:53:55 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-06-19 13:53:55 (GMT)
commitae5a132ce233ac3f5845db3daf94f09656d45954 (patch)
treeef8994d02c7b929a9a1214b526e0d82eae82f992 /program
parented2890927d79792e9222f61c19969352b614da8f (diff)
fixed end date for timeslots that start before and end after midnight.
Diffstat (limited to 'program')
-rw-r--r--program/models.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/program/models.py b/program/models.py
index 764cfbf..a63fcc7 100644
--- a/program/models.py
+++ b/program/models.py
@@ -195,10 +195,18 @@ class ProgramSlot(models.Model):
byweekday_start = self.byweekday
if self.tend < self.tstart:
- byweekday_end = self.byweekday + 1 if self.byweekday < 6 else 0
+ if self.byweekday < 6:
+ byweekday_end = self.byweekday + 1
+ else:
+ byweekday_end = 0
else:
byweekday_end = self.byweekday
+ if self.tend < self.tstart:
+ dend = self.dstart + timedelta(days=+1)
+ else:
+ dend = self.dstart
+
starts = list(rrule(freq=self.rrule.freq,
dtstart=datetime.combine(self.dstart, self.tstart),
interval=self.rrule.interval,
@@ -206,7 +214,7 @@ class ProgramSlot(models.Model):
bysetpos=self.rrule.bysetpos,
byweekday=byweekday_start))
ends = list(rrule(freq=self.rrule.freq,
- dtstart=datetime.combine(self.dstart, self.tend),
+ dtstart=datetime.combine(dend, self.tend),
interval=self.rrule.interval,
until=self.until+relativedelta(days=+1),
bysetpos=self.rrule.bysetpos,