Skip to content

Add support for weekly repeating events#14

Open
szabolcs-szilagyi wants to merge 2 commits intomsherry:masterfrom
szabolcs-szilagyi:master
Open

Add support for weekly repeating events#14
szabolcs-szilagyi wants to merge 2 commits intomsherry:masterfrom
szabolcs-szilagyi:master

Conversation

@szabolcs-szilagyi
Copy link
Copy Markdown

This adds support for events that repeats on chosen days of the week. E.g. repeating every Tuesday and Monday.

The solution isn't the most elegant, as we parse the date again from a previously parsed, then formatted source (the date variable), but for a more elegant solution we would need to refactor other methods as well.

For the repeating the following format is used (note the dates beneth):

* Pretend to do some sport
  :PROPERTIES:
  :ID:        a3f62a3f-5d6f-4956-9adc-a94b73438b34
  :LOCATION:  Local Gym
  :STATUS:    CONFIRMED
  :ATTENDING: ATTENDING
  :ATTENDEES:
  :END:
  :LOGBOOK:
  CLOCK: [2023-07-15 Sat 10:15]--[2023-07-15 Sat 10:30] =>  0:00
  :END
<2023-07-17 Mon 10:15-10:30 +1w>
<2023-07-18 Tue 10:15-10:30 +1w>
<2023-07-19 Wed 10:15-10:30 +1w>
<2023-07-20 Thu 10:15-10:30 +1w>

Other solution could be to use a lisp expression to setup, but for me that is too obsucre, hard to read at glance. E.g.:

** Daily meeting
   <%%(memq (calendar-day-of-week date) '(1 2 3 4 5))>

source: https://orgmode.org/worg/org-faq.html#orga9d21b4

Possible solution for #6

This adds support for events that repeats on chosen days of the week. E.g.
repeating every Tuesday and Monday.

The solution isn't the most elegant, as we parse the date again from a
previously parsed, then formatted source (the `date` variable), but for a more
elegant solution we would need to refactor other methods as well.

For the repeating the following format is used (note the dates beneth):
```
* Pretend to do some sport
  :PROPERTIES:
  :ID:        a3f62a3f-5d6f-4956-9adc-a94b73438b34
  :LOCATION:  Local Gym
  :STATUS:    CONFIRMED
  :ATTENDING: ATTENDING
  :ATTENDEES:
  :END:
  :LOGBOOK:
  CLOCK: [2023-07-15 Sat 10:15]--[2023-07-15 Sat 10:30] =>  0:00
  :END
<2023-07-17 Mon 10:15-10:30 +1w>
<2023-07-18 Tue 10:15-10:30 +1w>
<2023-07-19 Wed 10:15-10:30 +1w>
<2023-07-20 Thu 10:15-10:30 +1w>
```

Other solution could be to use a lisp expression to setup, but for me that is
too obsucre, hard to read at glance. E.g.:
```
** Daily meeting
   <%%(memq (calendar-day-of-week date) '(1 2 3 4 5))>
```
source: https://orgmode.org/worg/org-faq.html#orga9d21b4
The previous solution wouldn't reconigize, if the event is repeating on a single
day. With the new pattern the grouping goes like follows:
- two uppercase letter
- followed by an optional coma
- one or more repeats of the above two
- the above group followed by an optional semicolon
@szabolcs-szilagyi
Copy link
Copy Markdown
Author

szabolcs-szilagyi commented Sep 17, 2023

Interestingly the CLOCK entry is somehow incorrect in the above example. I've tested the code again and its okay.

Sample event that can be used for testing:

BEGIN:VEVENT
RRULE:FREQ=WEEKLY;UNTIL=20240314T084500Z;INTERVAL=1;BYDAY=MO,TU,WE,TH;WKST=
 SU
UID:d368d522-cf25-474e-85ba-48aca6ee254f
SUMMARY:Pretend to do sport
DTSTART;TZID=Central Europe Standard Time:20230815T094500
DTEND;TZID=Central Europe Standard Time:20230815T100000
CLASS:PUBLIC
PRIORITY:5
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:1
LOCATION:Local Gym
X-MICROSOFT-CDO-APPT-SEQUENCE:1
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:1
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MICROSOFT-REQUESTEDATTENDANCEMODE:DEFAULT
END:VEVENT

Will produce the following:

#+TITLE:       Main Google calendar entries
#+AUTHOR:      Marc Sherry
#+EMAIL:       unknown
#+DESCRIPTION: converted using the ical2org awk script
#+CATEGORY:    unknown
#+STARTUP:     hidestars
#+STARTUP:     overview
#+FILETAGS:    unknown

* COMMENT original iCal preamble

* Pretend to do sport
  :PROPERTIES:
  :ID:        d368d522-cf25-474e-85ba-48aca6ee254f
  :LOCATION:  Local Gym
  :STATUS:    CONFIRMED
  :ATTENDING: ATTENDING
  :ATTENDEES: 
  :END:
  :LOGBOOK:
  CLOCK: [2023-08-15 Tue 09:45]--[2023-08-15 Tue 10:00] =>  0:00
  :END
<2023-08-15 Tue 09:45-10:00 +1w>
<2023-08-16 Wed 09:45-10:00 +1w>
<2023-08-17 Thu 09:45-10:00 +1w>
<2023-08-21 Mon 09:45-10:00 +1w>

** COMMENT original iCal entry
 
BEGIN:VEVENT
RRULE:FREQ=WEEKLY;UNTIL=20240314T084500Z;INTERVAL=1;BYDAY=MO,TU,WE,TH;WKST=
 SU
UID:d368d522-cf25-474e-85ba-48aca6ee254f
SUMMARY:Pretend to do sport
DTSTART;TZID=Central Europe Standard Time:20230815T094500
DTEND;TZID=Central Europe Standard Time:20230815T100000
CLASS:PUBLIC
PRIORITY:5
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:1
LOCATION:Local Gym
X-MICROSOFT-CDO-APPT-SEQUENCE:1
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:1
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MICROSOFT-REQUESTEDATTENDANCEMODE:DEFAULT
END:VEVENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant