[CalendarServer-changes] [7502] CalendarServer/branches/users/wsanchez/deployment/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 19 11:03:51 PDT 2011
Revision: 7502
http://trac.macosforge.org/projects/calendarserver/changeset/7502
Author: cdaboo at apple.com
Date: 2011-05-19 11:03:51 -0700 (Thu, 19 May 2011)
Log Message:
-----------
Fix bug where VTODO time-ranges were not calculated according to the spec.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/ical.py
CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/instance.py
Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/ical.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/ical.py 2011-05-19 18:02:00 UTC (rev 7501)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/ical.py 2011-05-19 18:03:51 UTC (rev 7502)
@@ -64,6 +64,10 @@
#"VAVAILABILITY",
)
+# Used for min/max time-range query limits
+minDateTime = datetime.datetime(1900, 1, 1, 0, 0, 0, tzinfo=utc)
+maxDateTime = datetime.datetime(2100, 1, 1, 0, 0, 0, tzinfo=utc)
+
class Property (object):
"""
iCalendar Property
@@ -570,6 +574,32 @@
else:
return None
+ def getCompletedDateUTC(self):
+ """
+ Return the completed date or date-time for the specified component
+ converted to UTC.
+ @param component: the Component whose start should be returned.
+ @return: the datetime.date or datetime.datetime for the start.
+ """
+ completed = self.propertyNativeValue("COMPLETED")
+ if completed is not None:
+ return normalizeToUTC(completed)
+ else:
+ return None
+
+ def getCreatedDateUTC(self):
+ """
+ Return the created date or date-time for the specified component
+ converted to UTC.
+ @param component: the Component whose start should be returned.
+ @return: the datetime.date or datetime.datetime for the start.
+ """
+ created = self.propertyNativeValue("CREATED")
+ if created is not None:
+ return normalizeToUTC(created)
+ else:
+ return None
+
def getRecurrenceIDUTC(self):
"""
Return the recurrence-id for the specified component.
Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/instance.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/instance.py 2011-05-19 18:02:00 UTC (rev 7501)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/instance.py 2011-05-19 18:03:51 UTC (rev 7502)
@@ -223,19 +223,42 @@
@param component: the Component to expand
@param limit: the end datetime.datetime for expansion
"""
- start = component.getStartDateUTC()
- due = component.getDueDateUTC()
+ dtstart = component.getStartDateUTC()
+ dtend = component.getEndDateUTC()
+ dtdue = component.getDueDateUTC()
- if start is None and due is None:
- return
+ # DTSTART and DURATION or DUE case
+ if dtstart is not None:
+ start = dtstart
+ if dtend is not None:
+ end = dtend
+ elif dtdue is not None:
+ end = dtdue
+ else:
+ end = dtstart
+
+ # DUE case
+ elif dtdue is not None:
+ start = end = dtdue
+
+ # Fall back to COMPLETED or CREATED
+ else:
+ from twistedcaldav.ical import maxDateTime, minDateTime
+ dtcreated = component.getCreatedDateUTC()
+ dtcompleted = component.getCompletedDateUTC()
+ if dtcompleted:
+ end = dtcompleted
+ start = dtcreated if dtcreated else dtend
+ elif dtcreated:
+ start = dtcreated
+ end = maxDateTime
+ else:
+ start = minDateTime
+ end = maxDateTime
- if start is None:
- start = due
- elif due is None:
- due = start
- duration = differenceDateTime(start, due)
+ duration = differenceDateTime(start, end)
- self._addMasterComponent(component, limit, start, due, duration)
+ self._addMasterComponent(component, limit, start, end, duration)
def _addOverrideToDoComponent(self, component):
"""
@@ -247,19 +270,41 @@
#TODO: This does not take into account THISANDPRIOR - only THISANDFUTURE
- start = component.getStartDateUTC()
- due = component.getDueDateUTC()
+ dtstart = component.getStartDateUTC()
+ dtend = component.getEndDateUTC()
+ dtdue = component.getDueDateUTC()
- if start is None and due is None:
- return
+ # DTSTART and DURATION or DUE case
+ if dtstart is not None:
+ start = dtstart
+ if dtend is not None:
+ end = dtend
+ elif dtdue is not None:
+ end = dtdue
+ else:
+ end = dtstart
+
+ # DUE case
+ elif dtdue is not None:
+ start = end = dtdue
+
+ # Fall back to COMPLETED or CREATED
+ else:
+ from twistedcaldav.ical import maxDateTime, minDateTime
+ dtcreated = component.getCreatedDateUTC()
+ dtcompleted = component.getCompletedDateUTC()
+ if dtcompleted:
+ end = dtcompleted
+ start = dtcreated if dtcreated else dtend
+ elif dtcreated:
+ start = dtcreated
+ end = maxDateTime
+ else:
+ start = minDateTime
+ end = maxDateTime
- if start is None:
- start = due
- elif due is None:
- due = start
+ self._addOverrideComponent(component, start, end)
- self._addOverrideComponent(component, start, due)
-
def _addMasterComponent(self, component, limit, start, end, duration):
# Always add first instance if included in range.
if compareDateTime(start, limit) < 0:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110519/ddbd2572/attachment.html>
More information about the calendarserver-changes
mailing list