iCal 在最近的工作日可能每月重复一次活动吗?

iCal Recurring monthly event on the closest weekday possible?

我想在每个月的 24 日创建一个周期性事件,如果这一天是周末,则将其安排在最近的工作日。如果那天是星期六,我想安排在前一个工作日(星期五)。如果这一天是星期天,我想安排在下一个工作日(星期一)。这是可以用 iCal RRULE 做的事情吗?

我已经看到过类似的 question,但那总是下一个工作日。

我能够使用这个组合的 iCAL RRULE 根据您的要求创建一个周期性事件

RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=23,24;BYSETPOS=-1
RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=24,25;BYSETPOS=1

RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=23,24;BYSETPOS=-1

  • 通过将 BYSETPOS 设置为 -1,此规则将选择与规则匹配的事件集中的最后一个事件。

If both 23 and 24 falls on weekdays, it will choose the last occurrence which is the 24th day

If 24 falls on a Saturday, only one occurrence will be matched based on the rule, Hence it will choose the 23rd day on Friday

If both 23 and 24 fall on weekends, no event will be created. This is why another rule is needed to resolve this issue.

RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=24,25;BYSETPOS=1

  • 通过将 BYSETPOS 设置为 1,此规则将选择与规则匹配的事件集中的第一个事件。

If both 24 and 25 falls on weekdays, it will choose the first occurrence which is the 24th day

If 24 falls on a Sunday, only one occurrence will be matched based on the rule, Hence it will choose the 25th day on Monday

If both 24 and 25 fall on weekends, no event will be created based on this rule.