简体   繁体   English

Android日历事件年度重复重复规则

[英]android calendar event yearly repeating recurrence rule

I'm trying to add event in the calendar programatically. 我正在尝试以编程方式在日历中添加事件。 I want the event to repeat yearly, every first Monday in February for example. 我希望该活动每年重复一次,例如在2月的每个第一个星期一。 The rule I'm using is this: 我使用的规则是这样的:

FREQ=YEARLY;BYDAY=1MO;BYMONTH=2;INTERVAL=1;COUNT=11;

The problem is: if I create the event with starting date in January and set it to repeat every January, then it works fine. 问题是:如果我以1月开始的日期创建事件并将其设置为每年1月重复一次,那么它可以正常工作。 But, If i create the event with starting date in other month other than February, and set it to repeat by the same rule, the event won't repeat on Monday but on some other day. 但是,如果我创建的活动的开始日期是2月以外的其他月份,并按照相同的规则将其设置为重复,则该活动不会在星期一重复,而是在另一天重复。 That day is different depending in which month is the starting day of the event. 该日期有所不同,具体取决于事件的开始日期是哪个月。 It seems like it counts number of day because on the leap year the day is changed by one. 似乎很重要,因为在the年,这一天被更改了一天。

UPDATE: 更新:

I noticed that if I create an event as mentioned above the following happens: If I create the event for example in February and set to be repeated in March, the rule gets the number of days in month from the moth where the DTSTART of the event is set (February). 我注意到,如果如上所述创建事件,则会发生以下情况:如果例如在2月创建事件并设置为在3月重复,则该规则将从事件的DTSTART所在的月蛾中获取天数。设置(2月)。 So, if I create an event in February and set it to be repeated the last day in March it will be repeated every 28th March or 29th on leap years (instead of 31st as expected). 因此,如果我在2月创建一个活动并将其设置为在3月的最后一天重复,那么它将在March年的3月28日或29日重复(而不是预期的31日)。

Another example: I create event with DTSTART in January 2013 and set it to be repeated every first Monday in February. 另一个示例:我在2013年1月使用DTSTART创建了活动,并将其设置为在2月的每个第一个星期一重复一次。 It creates the event on the date in February 2013 that corresponds to the first Monday in January 2013, in this case that is 7th February (because 7th January is first Monday in January 2013). 它在2013年2月的日期(对应于2013年1月的第一个星期一)创建事件,在本例中为2月7日(因为1月7日是2013年1月的第一个星期一)。 Every next year the event will be repeated on the first Thursday of February. 明年,该活动将在2月的第一个星期四重复。

添加事件时, DTSTART必须与该事件的首次发生在同一个月,以避免产生不必要的副作用

can you give more details in terms of what you have and what you expect: 您能否根据自己的期望和期望给出更多详细信息:

BEGIN:VCALENDAR
PRODID:byhand
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:20130205T090000Z
UID:SO_14702482_2b
SUMMARY:SO_14702482_2b
DTSTART:20130104T090000Z
RRULE:FREQ=YEARLY;BYDAY=1MO;BYMONTH=2;INTERVAL=1;COUNT=11;
END:VEVENT
END:VCALENDAR

will occur (tested on 2 different platforms) @09h00Z on: 20130104,20130204,20140203, 20150202,20160201, 20170206,... 将会发生(在2个不同的平台上测试)@ 09h00Z on:20130104,20130204,20140203,20150202,20160201,20170206,...

while

BEGIN:VCALENDAR
PRODID:byhand
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:20130205T090000Z
UID:SO_14702482_1b
SUMMARY:SO_14702482_1b
DTSTART:20130204T090000Z
RRULE:FREQ=YEARLY;BYDAY=1MO;BYMONTH=2;INTERVAL=1;COUNT=11;
END:VEVENT
END:VCALENDAR

will occur (here also tested) @09h00Z on: 20130204, 20140203, 20150202,20160201, 20170206,... 将会在以下位置发生(此处也经过测试)@ 09h00Z:20130204、20140203、20150202、20160201、20170206,...

the main difference being that as RFC5545 specified, DTSTART is part of the occurences. 主要区别在于,按照RFC5545的规定,DTSTART是其中一部分。

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

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