Fix display of multiday events #100
@ -83,17 +83,23 @@ class GregorianCalendar(CalendarSystem):
|
|||||||
def days(self):
|
def days(self):
|
||||||
day_list = []
|
day_list = []
|
||||||
|
|
||||||
start_day = self.timestamp.replace(day=1)
|
month_first = self.timestamp.replace(day=1)
|
||||||
|
|
||||||
while start_day.weekday() > self.START_DAY:
|
if self.timestamp.month == 12:
|
||||||
start_day -= timedelta(days=1)
|
month_last = month_first.replace(day=31)
|
||||||
|
else:
|
||||||
|
month_last = month_first.replace(month=month_first.month + 1) - timedelta(days=1)
|
||||||
|
|
||||||
day_list.append(start_day)
|
pad_before = (7 - self.START_DAY + month_first.weekday()) % 7
|
||||||
current_day = start_day
|
pad_after = (6 - month_last.weekday() + self.START_DAY) % 7
|
||||||
|
|
||||||
while current_day.weekday() < self.END_DAY and current_day.month <= self.timestamp.month:
|
first_display = month_first - timedelta(days=pad_before)
|
||||||
current_day += timedelta(days=1)
|
last_display = month_last + timedelta(days=pad_after)
|
||||||
day_list.append(current_day)
|
current = first_display
|
||||||
|
|
||||||
|
while current <= last_display:
|
||||||
|
day_list.append(current)
|
||||||
|
current += timedelta(days=1)
|
||||||
|
|
||||||
return day_list
|
return day_list
|
||||||
|
|
||||||
@ -212,10 +218,8 @@ class GregorianCalendar(CalendarSystem):
|
|||||||
start_timestamp = date.replace(hour=0, minute=0, second=0, microsecond=0)
|
start_timestamp = date.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
end_timestamp = start_timestamp + timedelta(days=1)
|
end_timestamp = start_timestamp + timedelta(days=1)
|
||||||
|
|
||||||
events = events.filter(((Event.start_time >= start_timestamp) &
|
events = events.filter((Event.start_time <= end_timestamp) &
|
||||||
(Event.start_time < end_timestamp)) |
|
(Event.end_time >= start_timestamp)) \
|
||||||
((Event.end_time >= start_timestamp) &
|
|
||||||
(Event.end_time < end_timestamp))) \
|
|
||||||
.order_by('start_time', 'end_time')
|
.order_by('start_time', 'end_time')
|
||||||
|
|
||||||
if user is None:
|
if user is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user