#
# Check for REPORT calendar-query of VTODO within time range
#
TYPE=REPORT
URL=http://mycaldav/caldav.php/user1/home/
HEADER=User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.8pre) Gecko/20071023 Sunbird/0.7
HEADER=Accept: text/xml
HEADER=Accept-Language: en-us,en;q=0.5
HEADER=Accept-Charset: utf-8,*;q=0.1
HEADER=Content-Type: text/xml; charset=utf-8
HEADER=Depth: 1
HEAD

BEGINDATA
<?xml version="1.0" encoding="UTF-8"?>
<calendar-query xmlns:D="DAV:" xmlns="urn:ietf:params:xml:ns:caldav">
  <D:prop>
    <D:getetag/>
    <calendar-data/>
  </D:prop>
  <filter>
    <comp-filter name="VCALENDAR">
      <comp-filter name="VTODO">
        <time-range start="20071101T110000Z" end="20080104T110000Z"/>
      </comp-filter>
    </comp-filter>
  </filter>
</calendar-query>
ENDDATA

QUERY
SELECT dtstart, due,
       rrule,
       summary
  FROM calendar_item JOIN caldav_data USING (dav_id)
 WHERE calendar_item.dav_name ~ '^/user1/home/'
   AND caldav_data.caldav_type = 'VTODO'
   AND (rrule IS NOT NULL OR dtstart IS NULL
        OR (
              (
                  (due IS NULL AND dtstart > '20071101T110000Z')
                  OR due > '20071101T110000Z'
              )
              AND  dtstart < '20080104T110000Z'
           )
    )
ENDQUERY

