A quicky for you Zopistas: I have some dates in a database, which govern when a story becomes live and when it expires. I need to do a test along the lines of: dtml-in stories if (startdate is past) and (expirydate is future) show the story /if /in I have seen the fmt parameters isPast and isFuture and this gives me a true/false response: <dtml-var startdate fmt=isPast> but how do I use that in an if test? I keep (as usual) getting syntax errors. Help! ---------------------- Andy Gates, Learning and Research Technology Andy.Gates@bristol.ac.uk - ICQ#74362415
----- Original Message ----- From: Andy Gates <Andy.Gates@bristol.ac.uk> To: <zope@zope.org> Sent: Thursday, July 06, 2000 4:06 PM Subject: [Zope] Newbie: Date checking?
A quicky for you Zopistas: I have some dates in a database, which govern when a story becomes live and when it expires. I need to do a test along the lines of:
dtml-in stories if (startdate is past) and (expirydate is future) show the story /if /in
I have seen the fmt parameters isPast and isFuture and this gives me a true/false response: <dtml-var startdate fmt=isPast> but how do I use that in an if test?
>>>> I keep (as usual) getting syntax errors. :)
<dtml-if "_.DateTime(startdate).isPast() and _.DateTime(expirydate).isFuture()"> ... ... </dtml-if> PM
Message-ID: <EXECMAIL.1000706153700.R@kosh.bris.ac.uk> Priority: NORMAL X-Mailer: Execmail for Win32 5.1 Build (9) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii"
<dtml-if "_.DateTime(startdate).isPast() and _.DateTime(expirydate).isFuture()"> ... </dtml-if>
I'll work it out one day, honest. Ta. AndyG
<dtml-if "_.DateTime(startdate).isPast() and _.DateTime(expirydate).isFuture()"> ... ... </dtml-if>
This gives: Error Type: TypeError Error Value: __div__ nor __rdiv__ defined for these operands The dates are pulled from an access (!) database where they are defined as date/time types. Me confoosed. Andy
<dtml-if "_.DateTime(startdate).isPast() and _.DateTime(expirydate).isFuture()">
... ... </dtml-if>
This gives: Error Type: TypeError Error Value: __div__ nor __rdiv__ defined for these operands
Is better to put some mor lines from Traceback Exception To see the modul and the line
The dates are pulled from an access (!) database where they are defined as date/time types.
Me confoosed.
Andy G
Me too. Someting like <dtml-if "_.DateTime('2000-03-03').isPast() and _.DateTime('2000-12-02').isFuture()"> STORY </dtml-if> or <dtml-if "ZopeTime('2000-03-03').isPast() and ZopeTime('2000-12-02').isFuture()"> STORY </dtml-if> works on Zope 2.1.4 and Zope 2.1.6 I was thinking that are strings, I have made this many, many times. btw: what type are IN ZOPE? If are date/type in Zope , I guess that you can use something like <dtml-if "startdate.isPast() and expirydate.isFuture()"> Maybe you are lucky, I didn't test it :) PM
Message-ID: <EXECMAIL.1000707094411.E@kosh.bris.ac.uk> Priority: NORMAL X-Mailer: Execmail for Win32 5.1 Build (9) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii"
Is better to put some mor lines from Traceback Exception To see the modul and the line
Here it is: Traceback (innermost last): File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 214, in publish_module File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 179, in publish File C:\PROGRA~1\WebSite\lib\python\Zope\__init__.py, line 202, in zpublisher_exception_hook (Object: ElementWithAttributes) File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 165, in publish File C:\PROGRA~1\WebSite\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: news_maintenance) File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 102, in call_object (Object: news_maintenance) File C:\PROGRA~1\WebSite\lib\python\OFS\DTMLMethod.py, line 150, in __call__ (Object: news_maintenance) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_String.py, line 502, in __call__ (Object: news_maintenance) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_In.py, line 691, in renderwob (Object: sql_news_search(story='%%')) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_Util.py, line 335, in eval (Object: _.DateTime(startdate).isPast()) (Info: startdate) File <string>, line 0, in ? File C:\PROGRA~1\WebSite\lib\python\DateTime\DateTime.py, line 545, in __init__ TypeError: (see above) Any clues? Andy
participants (2)
-
Andy Gates -
Marcel Preda