[Zope] compare two dates

Michel Pelletier michel@digicool.com
Mon, 20 Mar 2000 09:48:00 -0800


julio dinis wrote:
> 
> Hi all!
> 
> Sorry for this more python less zope question.
> 
> Lets say I have this two strings:
> 
> "13 Feb 2000 20:37:06 GMT"
> 
> and
> 
> "Fri, 21 Jan 2000 11:29:10 +0000"
> 
> I want to compare them has dates and not strings with the built-in cmp()
> func. What type of cast, conversion can I do. Or what module
> can I use for this. Is really anything already  done, I do not want
> to go scratchy :-)

from DateTime import DateTime

Now you can instantiate DateTime objects like so:

DateTime(string)

and compare them easily:

if date1 < date2:
  print 'foo'

-Michel