Refine calendar event data display, prevent overlapping and display
event's end time.
This commit is contained in:
@@ -5,8 +5,9 @@ CALENDAR_NAMES = {
|
||||
}
|
||||
DAY_NAMES = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"]
|
||||
MAX_ENTRIES = 8
|
||||
MAX_TITLE_LENGTH = 28
|
||||
MAX_META_LENGTH = 32
|
||||
# Reserve the right side of each row for start and end times.
|
||||
MAX_TITLE_LENGTH = 19
|
||||
MAX_META_LENGTH = 28
|
||||
|
||||
|
||||
def shorten(value, maximum):
|
||||
@@ -19,7 +20,9 @@ def shorten(value, maximum):
|
||||
def compact_event(event, calendar_name):
|
||||
start = event.get("start", "")
|
||||
all_day = "T" not in start
|
||||
end = event.get("end", "")
|
||||
time = "ganztägig" if all_day else start[11:16]
|
||||
end_time = "" if all_day or "T" not in end else end[11:16]
|
||||
|
||||
location = (event.get("location") or "").split("\n")[0].strip()
|
||||
meta = calendar_name
|
||||
@@ -29,6 +32,7 @@ def compact_event(event, calendar_name):
|
||||
return {
|
||||
"title": shorten(event.get("summary", "Ohne Titel"), MAX_TITLE_LENGTH),
|
||||
"time": time,
|
||||
"end": end_time,
|
||||
"meta": shorten(meta, MAX_META_LENGTH),
|
||||
"all_day": int(all_day),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user