summaryrefslogtreecommitdiffstats
path: root/pykolab/xml/utils.py
diff options
context:
space:
mode:
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
+
+