def get_now_event(self):
"""Access to the current Event in the calendar.
Returns:
The Event object corresponding to the current event in the calendar
or None if there is no event.
"""
now = datetime.now(timezone.utc)
while self.event_list and self.event_list[0].end < now:
self.event_list.pop(0)
if len(self.event_list) == 0:
return None
elif self.event_list[0].start < now < self.event_list[0].end:
return self.event_list[0]
else:
return None
评论列表
文章目录