3

We have a event every year on the weekend (Fr-Su) that includes the first Sunday of June. How would I create a iCalendar Event that expresses these three days (whole day events)?

Creating a rule for the first Sunday is easy. But for the Saturday and Friday, I did not succeed to create a rule that counts backwards (RFC 5545 says INTERVAL, COUNT must be positive]. Moreover I could not think of a different expression that would start from the Friday - it could be the last Friday of May, but also the first in June.

Community
  • 1
  • 1
trapicki
  • 1,881
  • 1
  • 18
  • 24
  • Are you using Python's rrule module? – Anup Yadav Apr 03 '18 at 06:23
  • Wouldn't it be easier to do a rule for the first Sunday of June, and simply count backwards 2 days to get the start of the event? – rlanvin Apr 03 '18 at 09:45
  • @rlanvin I would if I knew how. Ideas? – trapicki Apr 04 '18 at 15:03
  • Sorry I meant counting backwards with a script (Python or otherwise). I don't see a way to do that purely with a RRULE at the moment. – rlanvin Apr 04 '18 at 17:11
  • I asked a [very similar question (Friday before first Saturday)](https://stackoverflow.com/q/52592891/2583476) which was solvable. I wonder if the accepted (only) would adapt to your case. – Chris H Oct 02 '18 at 19:41

2 Answers2

1

The RRRULE specification in RFC 5545 is lacking in this regard. The INTERVAL and COUNT values are for the repeating events, not the event itself. I've come across a similar issue when trying to define the USA day "Black Friday", the day after the 4th Thursday in November (Friday after Thanksgiving). The 4th Friday in November could occur the day after the 4th Thursday, or the prior week. There is not a way that I have found to make a RRULE for this situation.

I believe you will need to code the events individually instead of using a recurring rule.

zcontent
  • 316
  • 3
  • 4
  • Wait what? Black Friday is the day after the 4th Thursday of November (so the 4th Friday of November), how/when can it occur the week before? – rlanvin Apr 04 '18 at 16:48
  • 1
    If the first of the month occurs on Friday, then the 4th Friday of the month will occur the week before the 4th Thursday of the month. See June 2018 for a month where this occurs. – zcontent Apr 10 '18 at 13:46
1

RRULE:FREQ=YEARLY;BYDAY=FR;BYMONTH=5,6;BYSETPOS=2;BYMONTHDAY=-2,-1,1,2,3,4,5,6,7' seems to do the trick.

How can I write an ICS file for the Friday before the first Saturday of the month? led me to the right track: with 'BYMONTHDAY' I can count backwards from the end of the month.

The Friday before the first Sunday of the next month can be the last or the second to last day of the previous month, or up to the 5th day of the month. If I include May and June, I will get a set that includes the day. 'BYSETPOS' allows me to choose the second of the found Fridays. To always have the second in the set being my desired day, I include the 6th and 7th day of the month, which gives me a stable first Friday in May. Possibly matched additional Fridays in June are discarded by 'BYSETPOS' anyway.

Extending this to Saturday is simple, and the first Sunday of June is trivial.

I developed the rule with rrule.js

https://jakubroztocil.github.io/rrule/#/rfc/RRULE:BYDAY=FR;BYMONTH=5,6;BYSETPOS=2;BYMONTHDAY=-2,-1,1,2,3,4,5,6,7

trapicki
  • 1,881
  • 1
  • 18
  • 24