summaryrefslogtreecommitdiffstats
path: root/pykolab/xml/utils.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-07-13 13:38:48 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-07-13 13:38:48 +0200
commit02b4f24ca5cf66fd108f723cb4bfb6319a9d93a8 (patch)
tree6f1ec88af0cf531d805fa497b934b5160b07708a /pykolab/xml/utils.py
parent02b4fb9b938a0a8db21241fdb7c223caca5f881e (diff)
downloadpykolab-02b4f24ca5cf66fd108f723cb4bfb6319a9d93a8.tar.gz
Add utils for common actions
Diffstat (limited to 'pykolab/xml/utils.py')
-rw-r--r--pykolab/xml/utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py
new file mode 100644
index 0000000..0959c80
--- /dev/null
+++ b/pykolab/xml/utils.py
@@ -0,0 +1,19 @@
+import datetime
+import pytz
+
+def to_dt(dt):
+ """
+ Convert a naive date or datetime to a tz-aware datetime.
+ """
+
+ if type(dt) == 'datetime.date' or not hasattr(dt, 'hour'):
+ dt = datetime.datetime(dt.year, dt.month, dt.day, 0, 0, 0, 0)
+
+ else:
+ if dt.tzinfo == None:
+ return dt.replace(tzinfo=pytz.utc)
+ else:
+
+ return dt
+
+