From ae5a132ce233ac3f5845db3daf94f09656d45954 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 19 Jun 2011 15:53:55 +0200 Subject: fixed end date for timeslots that start before and end after midnight. 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, -- cgit v0.10.2