Minor improvements to event handling

This commit is contained in:
Ace
2020-05-18 18:31:23 +02:00
parent 620211b0fb
commit 48510763a6
3 changed files with 64 additions and 30 deletions

View File

@@ -154,6 +154,22 @@ class icalendar:
self.parsed_events = []
@staticmethod
def all_day(event):
"""Check if an event is an all day event.
Returns True if event is all day, else False
"""
if not ('end' and 'begin') in event:
print('Events must have a starting and ending time')
raise Exception('This event is not valid!')
else:
begin, end = event['begin'], event['end']
duration = end - begin
if (begin.format('HH:mm') == '00:00' and end.format('HH:mm') == '00:00'
and duration.days >= 1):
return True
else:
return False
def show_events(self, fmt='DD MMM YY HH:mm'):
"""print all parsed events in a more readable way