如何使iCalendar(RFC 2445)每年重复进行一次 [英] How to have an iCalendar (RFC 2445) repeat YEARLY with duration

查看:267
本文介绍了如何使iCalendar(RFC 2445)每年重复进行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我未能成功制定出允许发生如下所示的事件的规则:

I have been unsuccessful in formulating a RRULE that would allow an event as shown below:

每年从4月的第一个星期日到5月的最后一天重复一次,持续到星期一,星期三和星期五,直到永远.

Repeats YEARLY, from first Sunday of April to last day of May, occuring on Monday, Wednesday and Friday, until forever.

FREQ = YEARLY; BYMONTH = 4; BYDAY = SU (请把每年四月的第一个星期日重复一次)

FREQ=YEARLY;BYMONTH=4;BYDAY=SU (gives me the first Sunday of April repeating yearly)

FREQ = YEARLY; BYMONTH = 5; BYMONTHDAY = -1 (请告诉我5月的最后一天每年重复一次)

FREQ=YEARLY;BYMONTH=5;BYMONTHDAY=-1 (gives me the last day of May repeating yearly)

但是我不知道如何在星期一,星期三和星期五的这些日期之间每年重复一次活动.

But I can't figure out how to have the event repeat yearly between those dates for Monday, Wednesday and Friday.

建议?

更新:评论没有足够的空间来回答克里斯的答案,所以我正在用更多信息来编辑问题.

Update: Comments don't have enough space to respond to Chris' answer, so I am editing the question with further information.

不幸的是,没有.我不知道这是我正在使用的DDay.iCal库,还是什么库,但这都不起作用.我发现日期开始不能是序数日期(第一个星期日等).它必须是特定日期,这使我的要求很难.即使使用多个RRULE,它似乎也不起作用:

Unfortunately, no. I don't know if it is the DDay.iCal library I'm using, or what, but that doesn't work either. I've found that the date start can't be an ordinal date (first Sunday, etc.)..it has to be a specific date, which makes it difficult for my requirements. Even using multiple RRULE's it doesn't seem to work:

BEGIN:VCALENDAR 
VERSION:2.0 
PRODID:-//DDay.iCal//NONSGML ddaysoftware.com//EN 
BEGIN:VEVENT 
CREATED:20090717T033307Z 
DTSTAMP:20090717T033307Z 
DTSTART:20090101T000000 
RRULE:FREQ=YEARLY;WKST=SU;BYDAY=MO,WE,FR;BYMONTH=4,5 
RRULE:FREQ=YEARLY;WKST=SU;BYDAY=1SU;BYMONTH=4 
RRULE:FREQ=YEARLY;WKST=SU;BYMONTH=5;BYMONTHDAY=-1 
SEQUENCE:0 
UID:352ed9d4-04d0-4f06-a094-fab7165e5c74 
END:VEVENT 
END:VCALENDAR

这看上去很正确(我什至在2009年1月1日开始活动),但是当我开始测试某些日子是否有效时,我得到的结果不正确.

That looks right on the face (I'm even starting the event on 1/1/2009), but when I start testing whether certain days are valid, I get incorrect results.

例如

4/1/2009 12:00:00 AM = True   // Should be False
4/6/2009 12:00:00 AM = True  
4/7/2009 12:00:00 AM = False
4/8/2009 12:00:00 AM = True
5/1/2009 12:00:00 AM = True
5/2/2009 12:00:00 AM = False
5/29/2009 12:00:00 AM = True
5/31/2009 12:00:00 AM = True  // Should be False
6/1/2009 12:00:00 AM = False

我正在使用道格拉斯日(Douglas Day)的DDay.iCal 软件,但我认为这不是该库中的错误.我认为这可能是iCalendar(RFC 2445)中的限制.

I'm using Douglas Day's DDay.iCal software, but I don't think it is a bug in that library. I think this might be a limitation in iCalendar (RFC 2445).

有想法吗?

推荐答案

Todd,

使用上面的3个规则将产生结果的并集,而不是相交.您说对了,RFC2445/5545中没有非常优美的方法.但是,如果在生成事件时能够以编程方式计算4月的第一个星期日,则应该可以进行以下操作:

Using the 3 RRULEs as you have above will produce a union of results, not an intersection. You're right that there isn't a very graceful way in RFC2445/5545. However, if you have the ability to programatically calculate the first Sunday in April while you generate the event, the following should work:

DTSTART:20090405T000000
RRULE:FREQ=YEARLY;BYDAY=MO,WE,FR;UNTIL=20090531T000000Z

这种方法至少看起来更接近您想要实现的目标.

This method at least seems closer to what you were trying to achieve.

-道格

这篇关于如何使iCalendar(RFC 2445)每年重复进行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆