Merge pull request #53 from aceisace/Agenda-module-fix
Agenda module fix
This commit is contained in:
commit
9a0266ed63
@ -20,7 +20,7 @@ border_top = int(middle_section_height * 0.02)
|
|||||||
border_left = int(middle_section_width * 0.02)
|
border_left = int(middle_section_width * 0.02)
|
||||||
|
|
||||||
"""Choose font optimised for the agenda section"""
|
"""Choose font optimised for the agenda section"""
|
||||||
font = ImageFont.truetype(NotoSans+'.ttf', fontsize)
|
font = ImageFont.truetype(NotoSans+'Medium.ttf', fontsize)
|
||||||
line_height = int(font.getsize('hg')[1] * 1.2) + 1
|
line_height = int(font.getsize('hg')[1] * 1.2) + 1
|
||||||
line_width = int(middle_section_width - (border_left*2))
|
line_width = int(middle_section_width - (border_left*2))
|
||||||
|
|
||||||
@ -44,17 +44,18 @@ def main():
|
|||||||
clear_image('middle_section')
|
clear_image('middle_section')
|
||||||
|
|
||||||
print('Agenda module: Generating image...', end = '')
|
print('Agenda module: Generating image...', end = '')
|
||||||
now = arrow.now()
|
now = arrow.now(get_tz())
|
||||||
|
today_start = arrow.get(now.year, now.month, now.day)
|
||||||
|
|
||||||
"""Create a list of dictionaries containing dates of the next days"""
|
"""Create a list of dictionaries containing dates of the next days"""
|
||||||
agenda_events = [{'date':now.replace(days=+_),
|
agenda_events = [{'date':today_start.replace(days=+_),
|
||||||
'date_str': now.replace(days=+_).format('ddd D MMM',locale=language),
|
'date_str': now.replace(days=+_).format('ddd D MMM',locale=language),
|
||||||
'type':'date'} for _ in range(max_lines)]
|
'type':'date'} for _ in range(max_lines)]
|
||||||
|
|
||||||
"""Copy the list from the icalendar module with some conditions"""
|
"""Copy the list from the icalendar module with some conditions"""
|
||||||
upcoming_events = fetch_events()
|
upcoming_events = fetch_events()
|
||||||
filtered_events = [events for events in upcoming_events if
|
filtered_events = [events for events in upcoming_events if
|
||||||
events.end.to(get_tz()) > now]
|
events.end > now]
|
||||||
|
|
||||||
"""Set print_events_to True to print all events in this month"""
|
"""Set print_events_to True to print all events in this month"""
|
||||||
if print_events == True and filtered_events:
|
if print_events == True and filtered_events:
|
||||||
@ -68,10 +69,6 @@ def main():
|
|||||||
and create a ready-to-display list for the agenda view"""
|
and create a ready-to-display list for the agenda view"""
|
||||||
for events in filtered_events:
|
for events in filtered_events:
|
||||||
if not events.all_day:
|
if not events.all_day:
|
||||||
|
|
||||||
events.end = events.end.to(get_tz())
|
|
||||||
events.begin = events.begin.to(get_tz())
|
|
||||||
|
|
||||||
agenda_events.append({'date': events.begin, 'time': events.begin.format(
|
agenda_events.append({'date': events.begin, 'time': events.begin.format(
|
||||||
'HH:mm' if hours == '24' else 'hh:mm a'), 'name':str(events.name),
|
'HH:mm' if hours == '24' else 'hh:mm a'), 'name':str(events.name),
|
||||||
'type':'timed_event'})
|
'type':'timed_event'})
|
||||||
|
@ -116,9 +116,9 @@ def main():
|
|||||||
if show_events == True:
|
if show_events == True:
|
||||||
"""Filter events which begin before the end of this month"""
|
"""Filter events which begin before the end of this month"""
|
||||||
upcoming_events = fetch_events()
|
upcoming_events = fetch_events()
|
||||||
|
|
||||||
calendar_events = [events for events in upcoming_events if
|
calendar_events = [events for events in upcoming_events if
|
||||||
events.begin.to(get_tz()) < month_end and
|
events.begin < month_end and events.begin.month == now.month]
|
||||||
events.begin.month == now.month]
|
|
||||||
|
|
||||||
"""Find days with events in the current month"""
|
"""Find days with events in the current month"""
|
||||||
days_with_events = []
|
days_with_events = []
|
||||||
|
@ -38,6 +38,11 @@ def fetch_events():
|
|||||||
for events in upcoming_events:
|
for events in upcoming_events:
|
||||||
if events.all_day and events.duration.days > 1:
|
if events.all_day and events.duration.days > 1:
|
||||||
events.end = events.end.replace(days=-2)
|
events.end = events.end.replace(days=-2)
|
||||||
|
|
||||||
|
if not events.all_day:
|
||||||
|
events.begin = events.begin.to(get_tz())
|
||||||
|
events.end = events.end.to(get_tz())
|
||||||
|
|
||||||
|
|
||||||
""" The list upcoming_events should not be modified. If you need the data from
|
""" The list upcoming_events should not be modified. If you need the data from
|
||||||
this one, copy the list or the contents to another one."""
|
this one, copy the list or the contents to another one."""
|
||||||
|
Loading…
Reference in New Issue
Block a user