From a5bfd90b5e799b15f4b58738461597e898cb06f6 Mon Sep 17 00:00:00 2001 From: Max G Date: Sun, 7 Apr 2019 12:54:34 +0200 Subject: [PATCH] Added simplified, multiday-aware prefix --- Calendar/SingelDayEventListDesign.py | 4 ++-- Calendar/TextFormatter.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Calendar/SingelDayEventListDesign.py b/Calendar/SingelDayEventListDesign.py index 400a25a..1e05663 100644 --- a/Calendar/SingelDayEventListDesign.py +++ b/Calendar/SingelDayEventListDesign.py @@ -1,12 +1,12 @@ from EventListDesign import EventListDesign from settings import hours from Assets import fonts, defaultfontsize, colors -from TextFormatter import event_prefix_str +from TextFormatter import event_prefix_str_sum font = fonts["regular"] class SingelDayEventListDesign (EventListDesign): """Specialized event list for day list design.""" def __init__ (self, size, events, font_size = defaultfontsize, line_spacing=2, event_prefix_rel_dates = [], col_spacing=5, general_color=colors["fg"], background_color=colors["bg"], highlight_color=colors["hl"]): - prefix_func = lambda x, rel_date : event_prefix_str(x, rel_date) + prefix_func = lambda x, rel_date : event_prefix_str_sum(x, rel_date) super().__init__(size, events, text_size=font_size, line_spacing=line_spacing, col_spacing=col_spacing, event_prefix_rel_dates = event_prefix_rel_dates, event_prefix_func=prefix_func, font_family=font, show_more_info=True, general_color=general_color, background_color=background_color, highlight_color = highlight_color) \ No newline at end of file diff --git a/Calendar/TextFormatter.py b/Calendar/TextFormatter.py index 8524347..a395458 100644 --- a/Calendar/TextFormatter.py +++ b/Calendar/TextFormatter.py @@ -8,6 +8,7 @@ multiday_begin_character = ' >' multiday_end_character = '< ' until_character = ' - ' allday_character = "•" +multiday_character = allday_character + allday_character allday_lang = { "en" : "All day", @@ -60,6 +61,15 @@ def event_prefix_str (event, relative_date=None): else: return event_time_detailed(event) +def event_prefix_str_sum (event, relative_date=None): + if relative_date is None: + relative_date = event.begin_datetime.date() + + if __is_multiday__(event): + return multiday_character + else: + return event_time_summary(event) + def event_time_summary (event): if event.allday: return allday_character