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

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

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


当前回答

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

其他回答

I would use a 'link' concept for all future recurring events. They are dynamically displayed in the calendar and link back to a single reference object. When events have taken place the link is broken and the event becomes a standalone instance. If you attempt to edit a recurring event then prompt to change all future items (i.e. change single linked reference) or change just that instance (in which case convert this to a standalone instance and then make change). The latter cased is slightly problematic as you need to keep track in your recurring list of all future events that were converted to single instance. But, this is entirely do-able.

因此,在本质上,有两类事件-单个实例和重复事件。

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

http://github.com/bakineggs/recurring_events_for

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

https://github.com/mlipper/runt

我正在处理以下问题:

http://github.com/elevation/event_calendar -日历的模型和助手 http://github.com/seejohnrun/ice_cube -令人敬畏的循环宝石 http://github.com/justinfrench/formtastic -简单表单

以及一个正在进行的gem,它将formtastic扩展为一个输入类型:recurrent (form。schedule:as =>:循环),它会呈现一个类似ical的界面和一个before_filter来将视图再次序列化到一个IceCube对象中。

我的想法是使它难以置信的容易添加循环属性到一个模型,并在视图中容易地连接它。都在几行字里。


这给了我什么?索引,可编辑,循环属性。

Events存储单个日实例,并在日历视图/helper中使用 说的任务。schedule存储了yaml的IceCube对象,所以你可以像这样调用:task.schedule.next_suggestion。

概述:我使用两个模型,一个平面,日历显示,和一个属性的功能。

您可以将事件存储为重复的,如果编辑了特定实例,则创建具有相同事件ID的新事件。然后,在查找事件时,搜索具有相同事件ID的所有事件以获得所有信息。我不确定您是否滚动了自己的事件库,或者您是否正在使用现有的事件库,因此可能无法实现。

Keep track of a recurrence rule (probably based on iCalendar, per @Kris K.). This will include a pattern and a range (Every third Tuesday, for 10 occurrences). For when you want to edit/delete a specific occurrence, keep track of exception dates for the above recurrence rule (dates where the event doesn't occur as the rule specifies). If you deleted, that's all you need, if you edited, create another event, and give it a parent ID set to the main event. You can choose whether to include all of the main event's information in this record, or if it only holds the changes and inherits everything that doesn't change.

请注意,如果允许不终止的递归规则,则必须考虑如何显示现在无限多的信息。

希望有帮助!