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