Re-ocurring Events

Robert Rawlins - Think Blue robert.rawlins at thinkbluemedia.co.uk
Fri Apr 27 06:42:37 EDT 2007


Ok, Almost done now, it seems to be working a real charm at the moment.

I need a little help on performing a quick if statement against a date
string. I have couple of date strings returned by

s.attributes.getNamedItem("start").nodeValue
s.attributes.getNamedItem("end").nodeValue

and I need to do and conditional that ensures start is before today's
date/time and end is after today's date/time.

The string looks like: '2007-01-01 00:00:00'

Do I have to convert this to a proper time object to do the comparison? Or
can I do it as a string?

Thanks,

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 Robert Rawlins - Think Blue
Sent: 27 April 2007 09:55
To: 'Laurent Pointal'
Cc: python-list at python.org
Subject: RE: Re-ocurring Events

Thanks for getting back to me Laurent.

I've now made some pretty tidy progress on this and -think- it's going to
shape up nicely, I'm just working on converting my date strings from the XML
into a date_struct and we should be good to go.

I'll keep you all posted.

Rob

-----Original Message-----
From: Laurent Pointal [mailto:laurent.pointal at limsi.fr] 
Sent: 27 April 2007 09:49
To: Robert Rawlins - Think Blue
Subject: Re: Re-ocurring Events

Robert Rawlins - Think Blue a écrit :
> 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 was not thinking about launchd itself, but about its XML configuration 
files which manage timed events, as you need.

> 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.

See datetime module, eventually third party mxDatetime.

> 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.

A+

Laurent.

-- 
Laurent POINTAL
CNRS-LIMSI dépt. CHM, groupes AMI et PS
Courriel: laurent.pointal at limsi.fr    (prof)
           laurent.pointal at laposte.net (perso)
Ouebe: http://www.limsi.fr/Individu/pointal/
Tél. 01 69 85 81 06 (prof)
Fax. 01 69 85 80 88



-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list