Extend import of recurrence rules

Support has been implemented for recurrence rule parts BYMONTH, BYMONTHDAY and
BYDAY.  A new test has been added.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen
2020-05-28 14:45:00 +02:00
committed by Lukas Fleischer
parent d2791b046a
commit 382e60ba69
8 changed files with 2284 additions and 29 deletions

View File

@@ -60,6 +60,7 @@ TESTS = \
ical-010.sh \
ical-011.sh \
ical-012.sh \
ical-013.sh \
next-001.sh \
next-002.sh \
next-003.sh \
@@ -138,6 +139,7 @@ EXTRA_DIST = \
data/ical-008.ical \
data/ical-009.ical \
data/ical-012.ical \
data/rfc5545.ical \
data/rfc5545 \
data/todo \
data/todo-export

View File

@@ -46,7 +46,25 @@ DTSTAMP:
UID:
DTSTART;VALUE=DATE:20200502
DTEND;VALUE=DATE:20200504
DESCRIPTION:The first weekend in May is a two-day event.
DESCRIPTION:The first weekend in May is a two-day event.\nNon-repeating event.
SUMMARY:First weekend in May
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;VALUE=DATE:20200502
DTEND;VALUE=DATE:20200504
DESCRIPTION:First weekend in May is a two-day event!\nRepeating event\, three years.
SUMMARY:First weekend in May
RRULE:FREQ=YEARLY;BYDAY=1SA;BYMONTH=5;COUNT=3
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART:20200502T000000
DTEND:20200504T000000
DESCRIPTION:First weekend in May is a two-day event!\nRepeating appointment.
SUMMARY:First weekend in May
RRULE:FREQ=YEARLY;BYDAY=1SA;BYMONTH=5;COUNT=3
END:VEVENT
END:VCALENDAR

238
test/data/rfc5545.ical Normal file
View File

@@ -0,0 +1,238 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970901T090000
SUMMARY:Every other week on Monday\, Wednesday\, and Friday until December 24\, 1997\, starting on Monday\, September 1\, 1997
RRULE:FREQ=WEEKLY;INTERVAL=2;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Every other week on Tuesday and Thursday\, for 8 occurrences
RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=8;WKST=SU;BYDAY=TU,TH
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970905T090000
SUMMARY:Monthly on the first Friday for 10 occurrences
RRULE:FREQ=MONTHLY;COUNT=10;BYDAY=1FR
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970905T090000
SUMMARY:Monthly on the first Friday until December 24\, 1997
RRULE:FREQ=MONTHLY;UNTIL=19971224T000000Z;BYDAY=1FR
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970907T090000
SUMMARY:Every other month on the first and last Sunday of the month for 10 occurrences
RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=10;BYDAY=1SU,-1SU
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970922T090000
SUMMARY:Monthly on the second-to-last Monday of the month for 6 months
RRULE:FREQ=MONTHLY;COUNT=6;BYDAY=-2MO
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970928T090000
SUMMARY:Monthly on the third-to-the-last day of the month\, forever
RRULE:FREQ=MONTHLY;BYMONTHDAY=-3
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Monthly on the 2nd and 15th of the month for 10 occurrences
RRULE:FREQ=MONTHLY;COUNT=10;BYMONTHDAY=2,15
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970930T090000
SUMMARY:Monthly on the first and last day of the month for 10 occurrences
RRULE:FREQ=MONTHLY;COUNT=10;BYMONTHDAY=1,-1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970910T090000
SUMMARY:Every 18 months on the 10th thru 15th of the month for 10 occurrences
RRULE:FREQ=MONTHLY;INTERVAL=18;COUNT=10;BYMONTHDAY=10,11,12,13,14,15
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
DURATION:PT1H
SUMMARY:Daily for 10 occurrences
RRULE:FREQ=DAILY;COUNT=10
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Every Tuesday\, every other month
RRULE:FREQ=MONTHLY;INTERVAL=2;BYDAY=TU
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970610T090000
SUMMARY:Yearly in June and July for 10 occurrences
RRULE:FREQ=YEARLY;COUNT=10;BYMONTH=6,7
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970310T090000
SUMMARY:Every other year on January\, February\, and March for 10 occurrences
RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=10;BYMONTH=1,2,3
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970519T090000
SUMMARY:Every 20th Monday of the year\, forever
RRULE:FREQ=YEARLY;BYDAY=20MO
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970313T090000
SUMMARY:Every Thursday in March\, forever
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=TH
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970605T090000
SUMMARY:Every Thursday\, but only during June\, July\, and August\, forever
RRULE:FREQ=YEARLY;BYDAY=TH;BYMONTH=6,7,8
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19980213T090000
SUMMARY:Every Friday the 13th\, forever
RRULE:FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970913T090000
SUMMARY:The first Saturday that follows the first Sunday of the month\, forever
RRULE:FREQ=MONTHLY;BYDAY=SA;BYMONTHDAY=7,8,9,10,11,12,13
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19961105T090000
SUMMARY:Every 4 years\, the first Tuesday after a Monday in November\, forever (U.S. Presidential Election day)
RRULE:FREQ=YEARLY;INTERVAL=4;BYMONTH=11;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970805T090000
SUMMARY:An example where the days generated makes a difference because of WKST
RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=MO
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970805T090000
SUMMARY:changing only WKST from MO to SU\, yields different results...
RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
DURATION:PT30M
SUMMARY:Daily until December 24\, 1997
RRULE:FREQ=DAILY;UNTIL=19971224T000000Z
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:20070115T090000
SUMMARY:An example where an invalid date (i.e.\, February 30) is ignored
RRULE:FREQ=MONTHLY;BYMONTHDAY=15,30;COUNT=5
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
DURATION:PT5M
SUMMARY:Every other day - forever
RRULE:FREQ=DAILY;INTERVAL=2
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Every 10 days\, 5 occurrences:
RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19980101T090000
SUMMARY:(1) Every day in January\, for 3 years:
RRULE:FREQ=YEARLY;UNTIL=20000131T140000Z;BYMONTH=1;BYDAY=SU,MO,TU,WE,TH,FR,SA
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19980101T090000
SUMMARY:(2) Every day in January\, for 3 years:
RRULE:FREQ=DAILY;UNTIL=20000131T140000Z;BYMONTH=1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Weekly for 10 occurrences
RRULE:FREQ=WEEKLY;COUNT=10
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Weekly until December 24\, 1997
RRULE:FREQ=WEEKLY;UNTIL=19971224T000000Z
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Every other week - forever
RRULE:FREQ=WEEKLY;INTERVAL=2;WKST=SU
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Weekly on Tuesday and Thursday for five weeks (UNTIL)
RRULE:FREQ=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH
END:VEVENT
BEGIN:VEVENT
DTSTAMP:
UID:
DTSTART;TZID=America/New_York:19970902T090000
SUMMARY:Weekly on Tuesday and Thursday for five weeks (COUNT)
RRULE:FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH
END:VEVENT
END:VCALENDAR

View File

@@ -8,13 +8,13 @@ if [ "$1" = 'actual' ]; then
cp "$DATA_DIR/conf" .calcurse || exit 1
"$CALCURSE" -D "$PWD/.calcurse" -i "$DATA_DIR/ical-003.ical"
"$CALCURSE" -D "$PWD/.calcurse" -s01/01/2000 -r365
"$CALCURSE" -D "$PWD/.calcurse" -s05/01/2020 --to 01/01/2022
"$CALCURSE" -D "$PWD/.calcurse" -s05/01/2020 --to 01/01/2023
cat "$PWD/.calcurse/notes"/*
rm -rf .calcurse || exit 1
elif [ "$1" = 'expected' ]; then
cat <<EOD
Import process report: 0052 lines read
6 apps / 1 event / 0 todos / 0 skipped
Import process report: 0070 lines read
7 apps / 2 events / 0 todos / 0 skipped
01/01/00:
- 00:00 -> 01:30
Recurring appointment
@@ -136,9 +136,14 @@ Import process report: 0052 lines read
Recurring appointment
05/02/20:
* First weekend in May
* First weekend in May
- 00:00 -> ..:..
First weekend in May
05/03/20:
* First weekend in May
- ..:.. -> 00:00
First weekend in May
05/26/20:
- 12:00 -> 13:17
@@ -182,6 +187,15 @@ Import process report: 0052 lines read
- 21:45 -> 22:00
monthly on 31th, count 10, exceptions 31/7/2020 and 31/1/2021
05/01/21:
* First weekend in May
- 00:00 -> ..:..
First weekend in May
05/02/21:
- ..:.. -> 00:00
First weekend in May
05/31/21:
- 21:45 -> 22:00
monthly on 31th, count 10, exceptions 31/7/2020 and 31/1/2021
@@ -201,7 +215,23 @@ Import process report: 0052 lines read
12/31/21:
- 21:45 -> 22:00
monthly on 31th, count 10, exceptions 31/7/2020 and 31/1/2021
05/07/22:
* First weekend in May
- 00:00 -> ..:..
First weekend in May
05/08/22:
- ..:.. -> 00:00
First weekend in May
First weekend in May is a two-day event!
Repeating appointment.
The first weekend in May is a two-day event.
Non-repeating event.
--
Import: multi-day event changed to one-day event
First weekend in May is a two-day event!
Repeating event, three years.
--
Import: multi-day event changed to one-day event
EOD

1800
test/ical-013.sh Executable file

File diff suppressed because it is too large Load Diff