Skip to content

Commit

Permalink
allow merge of overlapping events
Browse files Browse the repository at this point in the history
  • Loading branch information
brackendawson committed Jan 26, 2024
1 parent 91500e1 commit c432958
Show file tree
Hide file tree
Showing 6 changed files with 793 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ log level (default "info")
### Client
Enter the URL into your webcal client:
```
webcal://<this_server>/?cal=<webcal_url>[&inc=<query> ...][&exc=<query> ...]
webcal://<this_server>/?cal=<webcal_url>[&inc=<query> ...][&exc=<query> ...][&mrg=true]
```
Where:
* **this_server** is the address and path hosting this program.
* **cal** your upstream webcal link, including the protocol scheme (webcal, http, https) (Required).
* **inc** query for events to include in the form `<FIELD>=<regexp>` where **FIELD** is an iCal event field (eg `SUMMARY`) and **regexp** is an unbound regular expression. Multiple inc arguments are allowed, (default `SUMMARY=.*`).
* **exc** query for events to exclude in the form `<FIELD>=<regexp>` where **FIELD** is an iCal event field (eg `SUMMARY`) and **regexp** is an unbound regular expression. Multiple inc arguments are allowed.
* **mrg** optional parameter to merge overlapping events into the one event.

eg:
```
Expand Down
276 changes: 276 additions & 0 deletions fixtures/calMerged.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Inc.//macOS 14.2.1//EN
VERSION:2.0
X-APPLE-CALENDAR-COLOR:#1BADF8
X-WR-CALNAME:webcalmerge
BEGIN:VTIMEZONE
TZID:Europe/London
BEGIN:DAYLIGHT
DTSTART:19810329T010000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
TZNAME:BST
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:19961027T020000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
TZNAME:GMT
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20240126T142833Z
DESCRIPTION:note
DTEND;TZID=Europe/London:20240122T100000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240122T090000
LAST-MODIFIED:20240126T160342Z
SEQUENCE:1
SUMMARY:not overlap 1
TRANSP:OPAQUE
UID:2B91A4FD-54B3-43B0-ADE3-820E82BF4E88
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T142844Z
DTEND;TZID=Europe/London:20240122T120000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240122T110000
LAST-MODIFIED:20240126T142854Z
SEQUENCE:1
SUMMARY:not overlap 2
TRANSP:OPAQUE
UID:8D66C7BF-89E7-4C03-A7EB-6ABA70DFB927
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T142904Z
DTEND;TZID=Europe/London:20240122T140000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240122T130000
LAST-MODIFIED:20240126T142911Z
SEQUENCE:1
SUMMARY:not overlap 3
TRANSP:OPAQUE
UID:8C9B208F-A427-452F-A119-DD95DBC3A93B
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T142913Z
DTEND;TZID=Europe/London:20240122T160000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240122T150000
LAST-MODIFIED:20240126T142927Z
SEQUENCE:2
SUMMARY:not overlap 4
TRANSP:OPAQUE
UID:E755A482-507E-44BD-A15A-5132558E9483
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T142929Z
DTEND;TZID=Europe/London:20240122T170000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240122T160000
LAST-MODIFIED:20240126T142938Z
SEQUENCE:1
SUMMARY:not overlap 5
TRANSP:OPAQUE
UID:26BD1F01-96FD-464F-A2F2-CA73C6822E50
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T142941Z
DTEND;TZID=Europe/London:20240122T190000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240122T180000
LAST-MODIFIED:20240126T142949Z
SEQUENCE:1
SUMMARY:not overlap 6
TRANSP:OPAQUE
UID:3083DEF3-A55B-41B0-8FD0-17EC2C0ADDA1
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T142953Z
DTEND;TZID=Europe/London:20240122T200000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240122T190000
LAST-MODIFIED:20240126T143003Z
SEQUENCE:1
SUMMARY:not overlap 7
TRANSP:OPAQUE
UID:561BD7D2-46CB-4CA2-BA2C-95D5D8ABB2FF
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143007Z
DTEND;TZID=Europe/London:20240122T210000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240122T200000
LAST-MODIFIED:20240126T143015Z
SEQUENCE:1
SUMMARY:not overlap 8
TRANSP:OPAQUE
UID:6DC6C23E-F3DB-42E3-B55A-AA7C6D99458F
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143019Z
DESCRIPTION:note 3\n\n---\noverlap 1\n\nnote 2
DTEND;TZID=Europe/London:20240123T100000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240123T090000
LAST-MODIFIED:20240126T160403Z
SEQUENCE:1
SUMMARY:overlap2 + overlap 1
TRANSP:OPAQUE
UID:BDA1550E-2D67-42FC-AC3B-0FEB432BE791
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143055Z
DTEND;TZID=Europe/London:20240123T120000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240123T110000
LAST-MODIFIED:20240126T143149Z
SEQUENCE:2
SUMMARY:overlap3 + overlap 4 + overlap 5
TRANSP:OPAQUE
UID:8B4E6A07-3F62-4E30-AE65-021FC233AEB4
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143144Z
DTEND;TZID=Europe/London:20240123T143000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240123T130000
LAST-MODIFIED:20240126T143223Z
SEQUENCE:1
SUMMARY:overlap 2 end + overlap 2 start
TRANSP:OPAQUE
UID:965A7E2F-69A3-4235-9D01-5663AC311AE8
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143218Z
DTEND;TZID=Europe/London:20240123T170000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240123T150000
LAST-MODIFIED:20240126T143250Z
SEQUENCE:2
SUMMARY:overlap 3 end + overlap 3 start end + overlap 3 start
TRANSP:OPAQUE
UID:2806BD83-F35D-4451-BF72-1D27D999BE6C
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143332Z
DTEND;TZID=Europe/London:20240125T113000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240124T090000
LAST-MODIFIED:20240126T143401Z
SEQUENCE:2
SUMMARY:muldiday not overlap 1
TRANSP:OPAQUE
UID:4EDED467-5361-4CB5-B183-1A95843DE724
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143357Z
DTEND;TZID=Europe/London:20240126T113000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240125T123000
LAST-MODIFIED:20240126T143407Z
SEQUENCE:1
SUMMARY:multiday not overlap 2
TRANSP:OPAQUE
UID:BFE8498D-3008-4853-8F1E-86207654ADE1
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143429Z
DTEND;TZID=Europe/London:20240131T134500
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240129T091500
LAST-MODIFIED:20240126T143433Z
SEQUENCE:1
SUMMARY:multiday overlap 1 + multiday overlap 2
TRANSP:OPAQUE
UID:5E37FE07-CCA9-4701-8AEB-9466FBADFB50
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143456Z
DTEND;VALUE=DATE:20240203
DTSTAMP:20240126T160428Z
DTSTART;VALUE=DATE:20240202
LAST-MODIFIED:20240126T143505Z
SEQUENCE:1
SUMMARY:allday not overlap
TRANSP:TRANSPARENT
UID:F92F6FC3-F164-46B5-BDE0-77E037300E36
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:Reminder
TRIGGER:-PT15H
UID:C48B7E14-AE2C-4C6F-8A9F-1F0F4DFD27AC
X-APPLE-DEFAULT-ALARM:TRUE
X-WR-ALARMUID:C48B7E14-AE2C-4C6F-8A9F-1F0F4DFD27AC
END:VALARM
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143527Z
DTEND;VALUE=DATE:20240210
DTSTAMP:20240126T160428Z
DTSTART;VALUE=DATE:20240205
LAST-MODIFIED:20240126T143527Z
SEQUENCE:0
SUMMARY:allday overlap end + allday overlap start
TRANSP:TRANSPARENT
UID:A85C6B39-2A05-43B6-A142-CEF02F68871D
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:Reminder
TRIGGER:-PT15H
UID:C1D10B91-6452-4100-923F-FF421D84EB36
X-APPLE-DEFAULT-ALARM:TRUE
X-WR-ALARMUID:C1D10B91-6452-4100-923F-FF421D84EB36
END:VALARM
END:VEVENT
BEGIN:VEVENT
CREATED:20240126T143550Z
DTEND;TZID=Europe/London:20240212T100000
DTSTAMP:20240126T160428Z
DTSTART;TZID=Europe/London:20240212T090000
LAST-MODIFIED:20240126T143557Z
SEQUENCE:1
SUMMARY:overlap contains + overlap contained
TRANSP:OPAQUE
UID:B35AE4BD-AE90-495B-982A-EE1B3EF88894
X-APPLE-CREATOR-IDENTITY:com.apple.calendar
X-APPLE-CREATOR-TEAM-IDENTITY:0000000000
END:VEVENT
END:VCALENDAR
Loading

0 comments on commit c432958

Please sign in to comment.