什么是模拟在日历应用程序事件再次发生的最好方法是什么?应用程序、日历、发生、事件

2023-09-10 22:39:56 作者:看得真切

我建设需要支持周期性事件一组日历应用程序,但我已经拿出来处理这些事件的解决方案看起来像是一个黑客攻击。我可以限制遥遥领先可以看一下,然后立即生成的所有事件。或者,我可以存储事件的重复和动态显示他们时,一个看起来未来的日历上,但我不得不将其转换为如果有人想更改事件的特定实例的详细信息的正常事件。

I'm building a group calendar application that needs to support recurring events, but all the solutions I've come up with to handle these events seem like a hack. I can limit how far ahead one can look, and then generate all the events at once. Or I can store the events as repeating and dynamically display them when one looks ahead on the calendar, but I'll have to convert them to a normal event if someone wants to change the details on a particular instance of the event.

我敢肯定有一个更好的方式来做到这一点,但我还没有找到它。什么是模拟周期性事件,在那里你可以改变的细节或删除特定事件的情况下,最好的方法是什么?

I'm sure there's a better way to do this, but I haven't found it yet. What's the best way to model recurring events, where you can change details of or delete particular event instances?

(我使用的红宝石,但请不要让这些限制你的答案。如果有一个Ruby特定的库什么的,不过,这是很好的了解。)

(I'm using Ruby, but please don't let that constrain your answer. If there's a Ruby-specific library or something, though, that's good to know.)

推荐答案

我会用一个链接理念,为所有未来的经常性活动。它们被动态地显示在日历和链接回单个参考对象。当事件发生的链路中断,而该事件成为一个独立实例。如果你试图编辑重复发生的事件,然后迅速改变所有未来的项目(即改变单一链接引用)或改变只是实例(在这种情况下,将其转换为一个独立的实例,然后做出改变)。后者套管稍有问题,因为你需要跟踪你经常被转换为单一实例,所有的未来事件列表。但是,这完全是做-能。

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.

因此​​,在本质上,有2个班的事件 - 单实例和经常性的事件

So, in essence, have 2 classes of events - single instances and recurring events.