: Re-ocurring Events

Robert Rawlins - Think Blue robert.rawlins at thinkbluemedia.co.uk
Fri Apr 27 03:23:47 EDT 2007


Thank you guys for your suggestions.

I've been having a look at that launchd stuff from apple but couldn’t really
see how that applies to my requirements.

I've been putting some serious thought into how this should work as its
essentially the final part of the puzzle for my application, I'll have a
fully working model for my application.

I've been thinking about the possibility of using a combination of xpath to
search the XML with some loops which change the date. As events won't ever
be set to start before 01-01-2007 I can set that as the ceiling for my loop.
So when I'm searching for weekly events, I 'simply' take today's date and
time and loop from now until 01-01-2007 decrementing the date by a week each
iteration of the loop and then search the XML for events in that date, make
sense?

I know that's a fairly intensive way of doing it, but if it works it works.

Now, the loop is where I'm really struggling, I've not done any looping with
dates, can anyone give me a hand with this? How can I loop back in time from
now to beginning of 07 a week at a time? Do we have some form of dateAdd() I
can use with a while loop? Perhaps.

Date = (now)
While date > 2007-01-01:
	Date = dateAdd(date, -1, w)

Something to that effect? Then I can quickly xpath for every iteration of
the loop.

Thanks guys for any help.

Rob

-----Original Message-----
From: python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org
[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org]
On Behalf Of Laurent Pointal
Sent: 26 April 2007 15:33
To: python-list at python.org
Subject: Re: Re-ocurring Events

Daniel Nogradi a écrit :
>> 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"
>> />

May take a look at launchd (Apple) XML dialect, it may have at least the 
semantic for your need.

For other parts... elementtree, yes.

>> 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.
> 
> This will not solve all your problems, but a very convenient way of
> handling XML is the element tree module (that comes with python 2.5):
> http://docs.python.org/lib/module-xml.etree.ElementTree.html
> 
> HTH,
> Daniel
-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list