From e9c5b68a53b52f039c99c388b12d64607442948a Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Fri, 8 Nov 2019 20:24:17 +1300 Subject: [PATCH 1/1] handle events with duration rather than end time --- .mutt/icalparser | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.mutt/icalparser b/.mutt/icalparser index 38e2fe7..77e7fe2 100755 --- a/.mutt/icalparser +++ b/.mutt/icalparser @@ -13,8 +13,13 @@ COLUMNS = int(os.getenv('COLUMNS', 80))-10 WIDTH = max(len(i) for i in FIELDS) INDENT = WIDTH + len(COLSEP) -def dtstrs(start, end): - start, end = start.dt, end.dt +def dtstrs(event): + start, end = event.get('dtstart').dt, event.get('dtend') + if not end: + duration = event.get('duration').dt + end = start + duration + else: + end = end.dt def strftime(dt, strf): return dt.astimezone().strftime(strf) @@ -39,7 +44,7 @@ def parse_ics_file(fp): for event in cal.walk(): if event.name != "VEVENT": continue - print('{} → {}'.format(*dtstrs(event.get('dtstart'), event.get('dtend')))) + print('{} → {}'.format(*dtstrs(event))) flags = [] for k in ('status', 'class', 'transp', 'priority'): t = event.get(k) -- 2.39.5