1.1 --- a/imip_agent.py Wed Sep 24 16:48:32 2014 +0200
1.2 +++ b/imip_agent.py Thu Sep 25 23:21:21 2014 +0200
1.3 @@ -86,7 +86,9 @@
1.4 def get_utc_datetime(d, name):
1.5 value, attr = get_item(d, name)
1.6 dt = get_datetime(value, attr)
1.7 - if isinstance(dt, datetime):
1.8 + if not dt:
1.9 + return None
1.10 + elif isinstance(dt, datetime):
1.11 return dt.astimezone(timezone("UTC")).strftime("%Y%m%dT%H%M%SZ")
1.12 else:
1.13 return dt.strftime("%Y%m%d")
1.14 @@ -103,27 +105,29 @@
1.15 except UnknownTimeZoneError:
1.16 tz = None
1.17
1.18 - m = match_datetime_icalendar(value)
1.19 - if m:
1.20 - dt = datetime(
1.21 - int(m.group("year")), int(m.group("month")), int(m.group("day")),
1.22 - int(m.group("hour")), int(m.group("minute")), int(m.group("second"))
1.23 - )
1.24 + if attr.get("VALUE") in (None, "DATE-TIME"):
1.25 + m = match_datetime_icalendar(value)
1.26 + if m:
1.27 + dt = datetime(
1.28 + int(m.group("year")), int(m.group("month")), int(m.group("day")),
1.29 + int(m.group("hour")), int(m.group("minute")), int(m.group("second"))
1.30 + )
1.31
1.32 - # Impose the indicated timezone.
1.33 - # NOTE: This needs an ambiguity policy for DST changes.
1.34 + # Impose the indicated timezone.
1.35 + # NOTE: This needs an ambiguity policy for DST changes.
1.36
1.37 - tz = m.group("utc") and timezone("UTC") or tz or None
1.38 - if tz is not None:
1.39 - return tz.localize(dt)
1.40 - else:
1.41 - return dt
1.42 + tz = m.group("utc") and timezone("UTC") or tz or None
1.43 + if tz is not None:
1.44 + return tz.localize(dt)
1.45 + else:
1.46 + return dt
1.47
1.48 - m = match_date_icalendar(value)
1.49 - if m:
1.50 - return date(
1.51 - int(m.group("year")), int(m.group("month")), int(m.group("day"))
1.52 - )
1.53 + if attr.get("VALUE") == "DATE":
1.54 + m = match_date_icalendar(value)
1.55 + if m:
1.56 + return date(
1.57 + int(m.group("year")), int(m.group("month")), int(m.group("day"))
1.58 + )
1.59 return None
1.60
1.61 # Time management.
1.62 @@ -445,7 +449,10 @@
1.63
1.64 if not conflict:
1.65 insert_period(freebusy, (dtstart, dtend, self.uid))
1.66 - self.store.set_freebusy(attendee, freebusy)
1.67 +
1.68 + if self.get_value("TRANSP") in (None, "TRANSPARENT"):
1.69 + self.store.set_freebusy(attendee, freebusy)
1.70 +
1.71 self.store.set_event(attendee, self.uid, to_node(
1.72 {"VEVENT" : [(self.details, {})]}
1.73 ))
1.74 @@ -510,7 +517,7 @@
1.75 rwrite(("UID", {}, self.uid))
1.76
1.77 for start, end, uid in freebusy:
1.78 - rwrite(("FREEBUSY", {}, [start, end]))
1.79 + rwrite(("FREEBUSY", {"FBTYPE" : "BUSY"}, [start, end]))
1.80
1.81 cwrite(("VFREEBUSY", {}, record))
1.82