summaryrefslogtreecommitdiffstats
path: root/pykolab/xml
diff options
context:
space:
mode:
Diffstat (limited to 'pykolab/xml')
-rw-r--r--pykolab/xml/event.py4
-rw-r--r--pykolab/xml/utils.py26
2 files changed, 9 insertions, 21 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 102ebce..276bb6f 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -822,7 +822,7 @@ class Event(object):
raise ValueError, _("Invalid classification %r") % (classification)
def set_created(self, _datetime=None):
- if _datetime == None:
+ if _datetime is None or isinstance(_datetime, datetime.time):
_datetime = datetime.datetime.utcnow()
self.event.setCreated(xmlutils.to_cdatetime(_datetime, False, True))
@@ -1012,7 +1012,7 @@ class Event(object):
if isinstance(_datetime, datetime.datetime):
valid_datetime = True
- if _datetime == None:
+ if _datetime is None or isinstance(_datetime, datetime.time):
valid_datetime = True
_datetime = datetime.datetime.utcnow()
diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py
index d98575e..535e95c 100644
--- a/pykolab/xml/utils.py
+++ b/pykolab/xml/utils.py
@@ -85,28 +85,16 @@ def to_cdatetime(_datetime, with_timezone=True, as_utc=False):
datetime = _datetime.replace(tzinfo=pytz.utc)
with_timezone = False
- (
- year,
- month,
- day,
- ) = (
- _datetime.year,
- _datetime.month,
- _datetime.day,
- )
+ # Sometimes we deal with dummy 00000000T000000 values from iCalendar
+ # in such cases we end up with datetime.time objects
+ if not hasattr(_datetime, 'year'):
+ (year, month, day) = (1970, 1, 1)
+ else:
+ (year, month, day) = (_datetime.year, _datetime.month, _datetime.day)
if hasattr(_datetime, 'hour'):
- (
- hour,
- minute,
- second
- ) = (
- _datetime.hour,
- _datetime.minute,
- _datetime.second
- )
+ (hour, minute, second) = (_datetime.hour, _datetime.minute, _datetime.second)
_cdatetime = kolabformat.cDateTime(year, month, day, hour, minute, second)
-
else:
_cdatetime = kolabformat.cDateTime(year, month, day)