summaryrefslogtreecommitdiffstats
path: root/pykolab/xml/utils.py
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-03-04 15:50:51 -0500
committerThomas Bruederli <bruederli@kolabsys.com>2014-03-04 15:50:51 -0500
commitf4b9812231a169f48fd0a45fa788d4aa09026387 (patch)
tree23c6d5a30e0a61b36749572d6abfb6932d483a54 /pykolab/xml/utils.py
parent74c17bde3f0eb6d83730d3711c8b9d8f68c6c2dc (diff)
downloadpykolab-f4b9812231a169f48fd0a45fa788d4aa09026387.tar.gz
Basic support for recurring resource invitations
Diffstat (limited to 'pykolab/xml/utils.py')
-rw-r--r--pykolab/xml/utils.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py
index 780932d..2fddb24 100644
--- a/pykolab/xml/utils.py
+++ b/pykolab/xml/utils.py
@@ -1,16 +1,17 @@
import datetime
import pytz
import kolabformat
+from dateutil.tz import tzlocal
def to_dt(dt):
"""
Convert a naive date or datetime to a tz-aware datetime.
"""
- if isinstance(dt, datetime.date) and not isinstance(dt, datetime.datetime) or not hasattr(dt, 'hour'):
- dt = datetime.datetime(dt.year, dt.month, dt.day, 0, 0, 0, 0)
+ if isinstance(dt, datetime.date) and not isinstance(dt, datetime.datetime) or dt is not None and not hasattr(dt, 'hour'):
+ dt = datetime.datetime(dt.year, dt.month, dt.day, 0, 0, 0, 0, tzinfo=tzlocal())
- else:
+ elif isinstance(dt, datetime.datetime):
if dt.tzinfo == None:
return dt.replace(tzinfo=pytz.utc)