RRule for semi-weekly events - icalendar

I've been trying to figure out how to compose an RRULE that has events on alternating days each week; for example:
Week A: Monday at 4pm
Week B: Friday at 4pm
Where Week A and Week B alternate continuously into the future.
The closest I've gotten is this:
RRULE:FREQ=WEEKLY;COUNT=30;INTERVAL=2;BYDAY=MO,FR
which is close, but gives me the monday and friday on the same week. How can I code it to select the second friday in the two-week interval? This seems much less complex than much of what can be done with RRULEs, so I'm likely missing something obvious?

If this is intended to go on forever, with no 'COUNT', then I think the only way you can do it is to have two events.
Using any other of the BY's even BYSETPOS gets one into trouble at some point at the end of the year, or the end of the sequence as far as you defined it. Two events allows one to iterate the Monday and the Friday cleanly.
The choice of DTSTART for each event is crucial to be sure that you are recurring the right Fridays after the Mondays. You have something like M fm FM fm FM fm
From
https://calendar.google.com/calendar/ical/eppua87dpfnq85bsrrt2siqlcs%40group.calendar.google.com/public/basic.ics
BEGIN:VEVENT
DTSTART:20211022T160000Z
DTEND:20211022T170000Z
RRULE:FREQ=WEEKLY;WKST=MO;INTERVAL=2;BYDAY=FR
DTSTAMP:20211012T064353Z
UID:STACKTESTFRIDAY
CREATED:20171102T185254Z
DESCRIPTION:
LAST-MODIFIED:20211012T064141Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:Afternoon Tea on Friday
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20211011T160000Z
DTEND:20211011T180000Z
RRULE:FREQ=WEEKLY;WKST=MO;INTERVAL=2;BYDAY=MO
DTSTAMP:20211012T064353Z
UID:STACKTESTMONDAY
CREATED:20171102T185254Z
DESCRIPTION:
LAST-MODIFIED:20211012T064112Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:Afternoon Tea on Monday
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

Here another option that might work for you. In a YEARLY rule you can prepend the BYDAY elements with an offset n to identify the n-th instance of that weekday in the year.
If your recurring event starts on the 20th Monday of the year you could build a rule like this to iterate 30 instances with alternating weekdays.
RRULE:FREQ=YEARLY;BYDAY=20MO,21FR,22MO,23FR,24MO,25FR,26MO,27FR,28MO,29FR,30MO,31FR,32MO,33FR,34MO,35FR,36MO,37FR,38MO,39FR,40MO,41FR,42MO,43FR,44MO,45FR,46MO,47FR,48MO,49FR
Note, this assumes the year starts on a Saturday, Sunday or Monday.
If the year starts on a Tuesday, Wednesday, Thursday or Friday, the weekdays have to have the same number (because in that case the n-th Monday and the n+1-th Friday occur in the same week), i.e.
RRULE:FREQ=YEARLY;BYDAY=20MO,22FR,22MO,24FR,24MO,26FR,26MO,28FR,28MO,30FR,30MO,32FR,32MO,34FR,34MO,36FR,36MO,38FR,38MO,40FR,40MO,42FR,42MO,44FR,44MO,46FR,46MO,48FR,48MO,50FR

Related

Trigger Azure Data Factory Pipeline on second Friday from end of month and on Tues, Wed and Thurs of the same week

I need a Pipeline to trigger on the Monthend week (Tues, Wed, Thurs and Friday) of a month.
Monthend is defined as,
"Last but one" Friday Or
Second Friday from the end of the month.
For Example, For month of June 2021, 18th is the Monthend (Orange color as shown in the image)
Calendar Image
If its just on Monthend i.e. Second Friday from the end of calendar month, its easy. Just use Occurrance as -2 and day as Friday in the Scheduled trigger and add to a pipeline to trigger,
"schedule": {
"monthlyOccurrences": [
{
"day": "Friday",
"occurrence": -2
}
]
}
but I also need to run on the Tues, Wed and Thurs of the same week, which I find it difficult as these weekdays can be second or third from the end of the calendar month. For example: For June 2021, as shown in the image, I also need to run on 15th (Third Tuesday from the end of calendar month), 16th (Third Wednesday from the end of calendar month), 17th (Second Thursday from the end of calendar month).
Can you let me know if this can be implemented using triggers of Azure data factory? If not, any otherways of implementing? Thank You!
The scheduled trigger alone is not capable of that logic (as of 2021-05-04). Easiest solution would be to use some other scheduling application.
For a purely Data-Factory solution, schedule the trigger for all the days the desired days could possibly occur on. Then modify the pipeline to do logic to determine whether the current day is actually one of the desired days.
Implementation details and sample code
The logic:
Find the last day of the month (First of the next month less 1 day).
Subtract a week so you are in the second-to-last week
Loop over [0,-1,-2,-3,-4,-5,-6] as number of days to add to the date. This produces the dates of each day of the week.
Use the dayOfWeek function to change the date into which day of the week it is
Filter to get the Friday date
Ask whether today is between the Friday date and Friday date - 3 days

iCalendar repeat rule for x days before the 2nd Tuesday in the month

I have a meeting on every 2nd Tuesday of the month.
I need 10 days to prepare that meeting - this means I would need a recurring event "10 days before the 2nd Tuesday of the month"
(added via ical file)
I found iCalendar repeat rule for "the day after the second monday of the month" but I'm not sure how/if this applies to my situation/how to remodel it to fit my needs.
The issue is that since it's 10 days prior it may even be in the previous month in some cases (e.g. if the first day of the month is a Tuesday)
What is the correct command for this?
EDIT: the time is always from 8-10am just so it can be included.

RRULE for the weekend including the first sunday of a month

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.
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.
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

ical RRULE for "second week of January"?

What ical RRULE lets me choose the second (not necessarily full) week of January (for example)?
More specifically, the Sunday that starts the second week of January?
Usually, "1SU" would work, but if the month starts with Sunday itself, it would be "2SU", so I don't see an obvious solution here?
If you want the Sunday that starts the second week in January, you have to say that that Sunday can be any month day except the first (and obviously, only can be below the 8th day of the month).
The way to do this is to specify a RRULE with FREQ=YEARLY;BYMONTH=1 to specify January, BYDAY=SU to specify Sundays, BYMONTHDAY=2,3,4,5,6,7,8 to specify that your Sunday cannot be the 1st of the month and that you are only interested in the one starting the 2nd week of the month.
To summarize:
RRULE:FREQ=YEARLY;BYMONTH=1;BYDAY=SU;BYMONTHDAY=2,3,4,5,6,7,8

how to set event duration in ekevent in icalender?

I created event in iCalendar. Its start date is today and end date is next month 15th. and this is recurrence type of event . so if set event as recurrence event then changed end date as same as recurrence end date. I want to give time duration of event,like 3.30P.M to 6.30P.M. How to i set event duration ....
"DTSTART;TZID=US-Eastern:19970105T083000
RRULE:FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9; BYMINUTE=30
First, the "INTERVAL=2" would be applied to "FREQ=YEARLY" to arrive at "every other year".
Then, "BYMONTH=1" would be applied to arrive at "every January, every other year".
Then, "BYDAY=SU" would be applied to arrive at "every Sunday in January, every other year".
Then, "BYHOUR=8,9" would be applied to arrive at "every Sunday in January at 8 AM and 9 AM, every other year".
Then, "BYMINUTE=30" would be applied to arrive at "every Sunday in January at 8:30 AM and 9:30 AM, every other year".
Then, lacking information from RRULE, the second is derived from DTSTART, to end up in "every Sunday in January at 8:30:00 AM and 9:30:00 AM, every other year".
Similarly, if the BYMINUTE, BYHOUR, BYDAY, BYMONTHDAY or BYMONTH rule part were missing, the appropriate minute, hour, day or month would have been retrieved from the "DTSTART" property."
Please any one guide me how to set ...
I know how to recurrence rule is working but my question is how to set event duration.
No client that I know of support BYMINUTE and BYHOUR so unless this event is for your own application consumption, you are asking for trouble. IN any case, the very first instance will use the DTSTART value as the beginning, regardless of what you may have put in BYMINUTE and BYHOUR (see https://www.rfc-editor.org/rfc/rfc5545#section-3.8.5.3)
Then you can use DTEND or DURATION:
DTSTART;TZID=US-Eastern:19970105T083000
DTEND;TZID=US-Eastern:19970105T153000
or
DTSTART;TZID=US-Eastern:19970105T083000
DURATION:PT7H