我正在构建一个需要支持重复事件的组日历应用程序,但我提出的处理这些事件的所有解决方案似乎都很简单。我可以限制一个人可以看多远的未来,然后一次性生成所有事件。或者,我可以将事件存储为重复的,并在日历上动态显示它们,但如果有人想更改事件的特定实例的细节,则必须将它们转换为正常事件。

我相信有更好的办法,但我还没找到。对重复发生的事件建模的最佳方法是什么?在这种方法中,您可以更改或删除特定事件实例的细节?

(我使用Ruby,但请不要让这限制了你的回答。如果有ruby特定的库或其他东西,那么最好知道。)


当前回答

From these answers, I've sort of sifted out a solution. I really like the idea of the link concept. Recurring events could be a linked list, with the tail knowing its recurrence rule. Changing one event would then be easy, because the links stay in place, and deleting an event is easy as well - you just unlink an event, delete it, and re-link the event before and after it. You still have to query recurring events every time someone looks at a new time period never been looked at before on the calendar, but otherwise this is pretty clean.

其他回答

对于准备支付一些授权费用的。net程序员,您可能会找到Aspose。网络很有用…它包括一个iCalendar兼容库,用于重复约会。

From these answers, I've sort of sifted out a solution. I really like the idea of the link concept. Recurring events could be a linked list, with the tail knowing its recurrence rule. Changing one event would then be easy, because the links stay in place, and deleting an event is easy as well - you just unlink an event, delete it, and re-link the event before and after it. You still have to query recurring events every time someone looks at a new time period never been looked at before on the calendar, but otherwise this is pretty clean.

您可能想要查看iCalendar软件实现或标准本身(RFC 2445 RFC 5545)。 很快想到的是Mozilla项目http://www.mozilla.org/projects/calendar/,快速搜索也会显示http://icalendar.rubyforge.org/。

可以考虑其他选项,这取决于您将如何存储事件。您正在构建自己的数据库模式吗?使用基于icalendar的软件,等等?

我使用如下所述的数据库模式来存储递归参数

http://github.com/bakineggs/recurring_events_for

然后使用runt动态计算日期。

https://github.com/mlipper/runt

查看下面的文章,了解三个优秀的ruby日期/时间库。 对于递归规则和事件日历需要的其他东西,Ice_cube似乎是一个可靠的选择。 http://www.rubyinside.com/3-new-date-and-time-libraries-for-rubyists-3238.html