Re-ocurring Events

Michael Bentley michael at jedimindworks.com
Thu Apr 26 10:26:18 EDT 2007


On Apr 26, 2007, at 4:26 AM, Robert Rawlins - Think Blue wrote:
> A bit more of a complex one this time, and I thought I’d get your  
> opinions on the best way to achieve this. Basically I’m looking for  
> a way to describe a re-occurring event, like a calendar event or  
> appointment I guess. I’m likely to use an XML file for the  
> definition of the events, but imagine I’ve got an event that looks  
> something like this.
>
>
>
> <event start=”2007-01-01 12:00:00” end=”2007-01-01 15:00:00”  
> repeat=”daily” />
>
>
>
> Now what I want to do is be able to build a class which has a  
> function like ‘getCurrentEvent()’ which will return any events that  
> should be occurring at that time. So if the current system time and  
> date is 2007-01-03 13:00:00 then it will return THAT event to me,  
> but if it was say 2007-01-03 16:00:00 then it would not, as the  
> event isn’t ‘due’ to occur at that time. Make sense?
>
>
>
> What’s the best way of handling this? I’m really a little lost as  
> to how I might get started, checking a static date time isn’t a  
> problem, it’s when it comes to these re-occurring events that I  
> struggle a little. The idea is that I would have 5 core  
> repetitions, none, daily, weekly, monthly and annually.
>
>
>
> Or perhaps you guys have a more full proof method of describing the  
> event in the XML?
>
>
>
> Any suggestions are more than welcome guys, thanks again for all  
> your help recently.

This is a *nix based project, right?  If so, it might be useful to  
look into cron.





More information about the Python-list mailing list