From ba5e9da460eb6af32ff57d0435afaada7d35eb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 2 Dec 2011 16:18:46 +0100 Subject: [PATCH] add utility function to know if an event is now --- tabellio/agenda/event.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tabellio/agenda/event.py b/tabellio/agenda/event.py index 2aa6334..95d561e 100644 --- a/tabellio/agenda/event.py +++ b/tabellio/agenda/event.py @@ -88,7 +88,13 @@ class BaseEvent(Item): except IndexError: return '#' - + def is_now(self): + now = datetime.datetime.now() + if now < self.start: + return False + if self.end and now > self.end: + return False + return True class Event(BaseEvent): implements(IEvent)