summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pykolab/xml/event.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 8550714..98a91aa 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -302,11 +302,20 @@ class Event(object):
def get_date_text(self, date_format='%Y-%m-%d', time_format='%H:%M %Z'):
start = self.get_start()
end = self.get_end()
- if start.date() == end.date():
+ all_day = not hasattr(start, 'date')
+ start_date = start.date() if not all_day else start
+ end_date = end.date() if not all_day else end
+
+ if start_date == end_date:
end_format = time_format
else:
end_format = date_format + " " + time_format
+ if all_day:
+ time_format = ''
+ if start_date == end_date:
+ return start.strftime(date_format)
+
return "%s - %s" % (start.strftime(date_format + " " + time_format), end.strftime(end_format))
def get_exception_dates(self):