X-Git-Url: https://git.madduck.net/etc/mutt.git/blobdiff_plain/3bf865afb83630c9ce9f0380c5fc5030e9589730..e9c5b68a53b52f039c99c388b12d64607442948a:/.mutt/icalparser 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)