[Zope] date comparison

Michel Pelletier michel@digicool.com
Sun, 12 Mar 2000 02:25:19 -0800


Kyle Burnett wrote:
> 
> anyone know a quick way to compare two date strings without having to
> complete tear the string apart?

Use the DateTime Object, in python:

Py$ from DateTime import DateTime
Py$ DateTime() > DateTime('Jan 1, 1999')
1
Py$

in DTML:

<dtml-if "_.DateTime() > _.DateTime('Jan 1, 1999')">
  True.
</dtml-else>
  You should never see this unless the universe reversed itself.
</dtml-if>

Calling the DateTime object with no arguments means 'now'.  It accepts a
number of different date formats.  I just made this one up and it
happily accepted it.

In DTML, _.DateTime is synonymous with the global value ZopeTime.  So
the Second example is equivalent to:

<dtml-if "ZopeTime() > ZopeTime('Jan 1, 1999')">
  True.
</dtml-else>
  You should never see this unless the universe reversed itself.
</dtml-if>

-Michel