简体   繁体   English

iCalendar RFC5545 重复规则中是否可以有 OR 表达式?

[英]Is it possible to have an OR expression in a iCalendar RFC5545 recurrence rule?

I'm currently using iCalendar specification ( RFC 5545 ) to deal with recurring events.我目前正在使用 iCalendar 规范 ( RFC 5545 ) 来处理重复发生的事件。

Until yesterday, their recurrence rules covered all my needs, but now I'm having a hard time implementing the following rule:直到昨天,他们的重复规则涵盖了我的所有需求,但现在我很难实施以下规则:

Every month on the first Monday OR Wednesday of the month.每个月的第一个星期一星期三。

Ex:前任:

  • 2021-05-01 is Saturday: the event will happen on Monday 2021-05-03. 2021-05-01 是星期六:活动将于 2021-05-03 星期一举行。
  • 2021-06-01 is Tuesday: the event will happen on Wednesday 2021-06-02. 2021-06-01 是星期二:该事件将在 2021-06-02 星期三发生。
  • 2021-07-01 is Thursday: the event will happen on Monday 2021-07-05. 2021-07-01 是星期四:活动将在 2021-07-05 星期一举行。
  • 2021-08-01 is Sunday: the event will happen on Monday 2021-08-02. 2021-08-01 是星期日:活动将于 2021-08-02 星期一举行。

Is there a way to define this kind of "conditional" rule?有没有办法定义这种“条件”规则?

If I understand the requirement correctly, it is not exactly conditional.如果我正确理解了这个要求,它并不完全是有条件的。 It is that ONLY the first of the first Monday and first Wednesday is required.仅需要第一个星期一和第一个星期三中的第一个。 BYSETPOS is aimed at this. BYSETPOS 正是针对这一点。

In this example, it is being used to calculate the last working day https://icalevents.com/2555-paydays-last-working-days-and-why-bysetpos-is-useful/在此示例中,它用于计算最后一个工作日https://icalevents.com/2555-paydays-last-working-days-and-why-bysetpos-is-useful/

For your example对于你的例子

RRULE:FREQ=MONTHLY;BYDAY=1MO,1WE;BYSETPOS=1 RRULE:FREQ=MONTHLY;BYDAY=1MO,1WE;BYSETPOS=1

should do the trick,应该做的伎俩,

Basically the RRULE will expand out all the first MONDAY and WEDNESDAYs and then 'contract' ie take the first date of each pair.基本上,RRULE 将扩展所有第一个星期一和星期三,然后“合同”,即取每对的第一个日期。

Page 43 of the specification https://www.ietf.org/rfc/rfc5545.txt shows the priorities of the 'expansions' and 'contractions'.规范https://www.ietf.org/rfc/rfc5545.txt的第 43 页显示了“扩展”和“收缩”的优先级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM