如何为具有多个 BYSETPOS 值的重复事件生成 RRULE?
How to generate RRULE for recurring events with multiple BYSETPOS values?
我正在尝试为发生在每个月的第一个和第二个星期一和星期二的事件定义一个 RRULE。这相当于每月发生四次事件。我认为这是正确的:
FREQ=MONTHLY;INTERVAL=1;BYSETPOS=1,2;BYDAY=MO,TU
但它只会为每个月的 第 Monday/Tuesday 生成事件。如果我删除星期二,它将在该月的第一个和第二个星期一生成事件。为什么我不能指定多个 BYSETPOS 值(因为 RRULE spec 似乎允许)以及多个 BYDAY 值?
如何正确定义这样的规则,因为很明显这不是正确的方法?
显然我没有完全理解 BYSETPOS 属性。
上面链接的文档指出:
bysetpos - If given, it must be either an integer, or a sequence of integers,
positive or negative. Each given integer will specify an occurrence
number, corresponding to the nth occurrence of the rule inside the
frequency period. For example, a bysetpos of -1 if combined with a
MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will
result in the last work day of every month.
所以我认为使用 BYSETPOS 来指定频率周期内所需的出现次数(作为整数序列)是正确的。
感谢您的指导。
How would such a rule be properly defined
就像这样:BYDAY=1MO,1TU,2MO,2TU
来自RFC 5545的相关引述:
Each BYDAY value can also be preceded by a positive (+n) or
negative (-n) integer. If present, this indicates the nth
occurrence of a specific day within the MONTHLY or YEARLY "RRULE".
For example, within a MONTHLY rule, +1MO (or simply 1MO)
represents the first Monday within the month, whereas -1MO
represents the last Monday of the month.
Why can't I specify multiple BYSETPOS values (as the RRULE spec seems to allow) along with multiple BYDAY values?
你可以 - 实际上你用 BYSETPOS=1,2
指定了 2。你问的是第一个和第二个结果。但是您希望每个月出现 4 次(第一个星期一、第一个星期二、第二个星期一、第二个星期二),因此如果您 真的 想使用 BYSETPOS
,则应该指定 4 次:BYSETPOS=1,2,3,4
。不过我不推荐 BYSETPOS
,BYDAY
更清晰易懂。
我正在尝试为发生在每个月的第一个和第二个星期一和星期二的事件定义一个 RRULE。这相当于每月发生四次事件。我认为这是正确的:
FREQ=MONTHLY;INTERVAL=1;BYSETPOS=1,2;BYDAY=MO,TU
但它只会为每个月的 第 Monday/Tuesday 生成事件。如果我删除星期二,它将在该月的第一个和第二个星期一生成事件。为什么我不能指定多个 BYSETPOS 值(因为 RRULE spec 似乎允许)以及多个 BYDAY 值?
如何正确定义这样的规则,因为很明显这不是正确的方法?
显然我没有完全理解 BYSETPOS 属性。
上面链接的文档指出:
bysetpos - If given, it must be either an integer, or a sequence of integers, positive or negative. Each given integer will specify an occurrence number, corresponding to the nth occurrence of the rule inside the frequency period. For example, a bysetpos of -1 if combined with a MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will result in the last work day of every month.
所以我认为使用 BYSETPOS 来指定频率周期内所需的出现次数(作为整数序列)是正确的。
感谢您的指导。
How would such a rule be properly defined
就像这样:BYDAY=1MO,1TU,2MO,2TU
来自RFC 5545的相关引述:
Each BYDAY value can also be preceded by a positive (+n) or
negative (-n) integer. If present, this indicates the nth
occurrence of a specific day within the MONTHLY or YEARLY "RRULE".
For example, within a MONTHLY rule, +1MO (or simply 1MO)
represents the first Monday within the month, whereas -1MO
represents the last Monday of the month.
Why can't I specify multiple BYSETPOS values (as the RRULE spec seems to allow) along with multiple BYDAY values?
你可以 - 实际上你用 BYSETPOS=1,2
指定了 2。你问的是第一个和第二个结果。但是您希望每个月出现 4 次(第一个星期一、第一个星期二、第二个星期一、第二个星期二),因此如果您 真的 想使用 BYSETPOS
,则应该指定 4 次:BYSETPOS=1,2,3,4
。不过我不推荐 BYSETPOS
,BYDAY
更清晰易懂。