How can I write an ICS file for the Friday before the first Saturday of the month?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 04:58:32

问题


I've seen How can an ICS file be written for a recurring event? but I've got a rather complex recurrence and can't figure out a rule after looking at the syntax of RRULEs.

I want an event that happens on the Friday preceding the first Saturday of each month. This Friday-before-the-first-Saturday may of course be in the previous month. I assume that if I can get this to work, similar (but not identical) events for Friday-before-the-second-Saturday, and -third- and -fourth-, with Friday before 5th Saturdays undefined.

Obviously I'd have RRULE:FREQ=MONTHLY;BYDAY=FR; but if I try to follow some of the examples using BYMONTHDAY I run into trouble: 28 would be a valid Friday-before-a-first-Saturday in February, but in any other month, Friday 28th would be the Friday before a 5th Saturday. Similarly for 29 (in a leap year), 30 and 31.

The goal is to include this in a Google Calendar, which I know supports display of ICS RRULEs it can't edit. So, assuming it's possible, how can I create an RRULE for this event? I've considered a separate event and accompanying rule for each month length. 31: Jan, Mar, May, Jul, Aug, Oct, Dec and 30: Apr, Jun, Sep, Nov are OK, but leap years are still an issue: 28 Feb could be a Friday before a first Saturday or a 5th Saturday (e.g. 2020 so one of my first two cases fails).


回答1:


You're on the right track with having to use BYDAY=FR, AND since you can do negative BYMONTHDAY, the following should do the trick:

RRULE:FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=-1,1,2,3,4,5,6



来源:https://stackoverflow.com/questions/52592891/how-can-i-write-an-ics-file-for-the-friday-before-the-first-saturday-of-the-mont

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!