summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-07-09 19:23:52 -0400
committerThomas Bruederli <bruederli@kolabsys.com>2014-07-09 19:23:52 -0400
commit33fc8d4ba377a22e9c4c5a61e22fd7d1e217ffa8 (patch)
tree967b734ce07d9dc03f2187b06592ac9818e22484
parent2e506e215f44a6df7299ee0a424931b95fd5062c (diff)
downloadpykolab-33fc8d4ba377a22e9c4c5a61e22fd7d1e217ffa8.tar.gz
Better date text for all-day events
-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):