[Zope] Re: Date comparisons

Heimo Laukkanen huima@fountainpark.org
Wed, 23 Jan 2002 15:03:55 +0200


From: "Yvonne Totty" <ytotty@a...>
                To: "Zope" <zope@z...>
                Sent: Tuesday, January 22, 2002 13:13
                Subject: [Zope] Date Comparisons


                > Hi people,
                > 
                > I need to compare the current date to a
                > result from a query:
                > 
                > <dtml-if "DateResult>=TodaysDate">
                > 
                > Where DateResult is from the Query
                > and TodaysDate is Today's Date.
                > 
                > How would I go about this? I looked thru
                > all the docs, but could not find an example.

I am using in one of my DTMl-scripts the dtml-calendar. The
dtml-calendar gives the date as a DateTime-object ( in the script date
). I will get a DateTime object  for now with ZopeTime() call. For both
objects I then call Date()-function, which will produce a string of the
current date. Then I can compare these to each other.

<dtml-let d="date.Date()" hasdate="hasProperty(d)"
dprop="getProperty(d)" now="ZopeTime().Date()">
...
<dtml-if expr="d==now">

Hope this helps!

-huima