Fix RRULE for BYHOUR, BYMINUTE and BYSECOND

Closes #283.
This commit is contained in:
Andrew Ruthven 2023-02-07 00:45:45 +13:00
parent 8444347b02
commit c3970f3be2
4 changed files with 97 additions and 3 deletions

View File

@ -1,3 +1,6 @@
2022-02-07 Andrew Ruthven <andrew@etc.gen.nz>
* Fix Reccurrence Rules using BYHOUR, BYMINUTE and BYSECOND.
2022-12-18 Andrew Ruthven <andrew@etc.gen.nz>
* Numerous fixes for PHP 8.2
* Convert RRULE expansion loop limits, and make it configurable to resolve

View File

@ -1080,7 +1080,7 @@ class RepeatRule {
$instances = $this->current_set;
$this->current_set = array();
foreach( $instances AS $k => $instance ) {
foreach( $this->bymonth AS $k => $month ) {
foreach( $this->byhour AS $k => $hour ) {
$this->current_set[] = $this->date_mask( clone($instance), null, null, null, $hour, null, null);
}
}
@ -1090,7 +1090,7 @@ class RepeatRule {
$instances = $this->current_set;
$this->current_set = array();
foreach( $instances AS $k => $instance ) {
foreach( $this->bymonth AS $k => $month ) {
foreach( $this->byminute AS $k => $minute ) {
$this->current_set[] = $this->date_mask( clone($instance), null, null, null, null, $minute, null);
}
}
@ -1100,7 +1100,7 @@ class RepeatRule {
$instances = $this->current_set;
$this->current_set = array();
foreach( $instances AS $k => $instance ) {
foreach( $this->bymonth AS $k => $second ) {
foreach( $this->bysecond AS $k => $second ) {
$this->current_set[] = $this->date_mask( clone($instance), null, null, null, null, null, $second);
}
}

View File

@ -0,0 +1,46 @@
HTTP/1.1 201 Created
Date: Dow, 01 Jan 2000 00:00:00 GMT
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
ETag: "56c69ee579af9ef1ae32edaeac9d7e26"
Content-Length: 0
Content-Type: text/plain; charset="utf-8"
CalDAV Data: >BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VTODO
UID:takeoutthethrash
DTSTAMP:20221013T151313Z
DTSTART:20221017T065500Z
STATUS:NEEDS-ACTION
DURATION:PT10M
SUMMARY:Take out the thrash before the collectors come.
RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=6;BYMINUTE=55;COUNT=3
CATEGORIES:CHORE
PRIORITY:3
END:VTODO
END:VCALENDAR
<
caldav_type: >VTODO<
class: >PUBLIC<
dav_etag: >56c69ee579af9ef1ae32edaeac9d7e26<
description: >NULL<
dtend: >2022-10-17 20:05:00+13<
dtstamp: >2022-10-13 15:13:13<
dtstart: >2022-10-17 19:55:00+13<
due: >NULL<
location: >NULL<
logged_user: >10<
percent_complete: >NULL<
priority: >3<
rrule: >FREQ=WEEKLY;BYDAY=MO;BYHOUR=6;BYMINUTE=55;COUNT=3<
status: >NEEDS-ACTION<
summary: >Take out the thrash before the collectors come.<
transp: >NULL<
uid: >takeoutthethrash<
url: >NULL<
user_no: >10<
~ Modified Now: >0<

View File

@ -0,0 +1,45 @@
#
# PUT a fancy RRULE
#
# To test https://gitlab.com/davical-project/davical/-/issues/283
#
TYPE=PUT
URL=http://regression.host/caldav.php/user1/home/takeoutthethrash.ics
HEADER=User-Agent: DAViCal/1.12
HEADER=Accept: text/xml,application/xml
HEADER=Content-Type: text/calendar; charset=utf-8
HEAD
BEGINDATA
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VTODO
UID:takeoutthethrash
DTSTAMP:20221013T151313Z
DTSTART:20221017T065500Z
STATUS:NEEDS-ACTION
DURATION:PT10M
SUMMARY:Take out the thrash before the collectors come.
RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=6;BYMINUTE=55;COUNT=3
CATEGORIES:CHORE
PRIORITY:3
END:VTODO
END:VCALENDAR
ENDDATA
QUERY
SELECT caldav_data.user_no, caldav_data.dav_etag, caldav_type, logged_user,
uid, dtstamp, dtstart, dtend, due, summary, location,
description, priority, class, transp, rrule, url,
percent_complete, status,
caldav_data AS " CalDAV Data",
((current_timestamp AT TIME ZONE 'GMT' - calendar_item.last_modified) < '2 seconds'::interval) AS "~ Modified Now"
FROM caldav_data JOIN calendar_item USING(dav_name)
WHERE caldav_data.dav_name =
'/user1/home/takeoutthethrash.ics';
ENDQUERY