[Zope] Confused about manipulating dates in DTML

Kapil Thangavelu k_vertigo@yahoo.com
Fri, 21 Apr 2000 15:44:27 -0400


Hello,

from  your tracebacks it seems that what your passing in is not a string to date time.  i tried
both of the methods you list below passing in the string explicitly and they work fine. you
might have another variable named start in your namespace. you might want to try a  dtml-var
start and see what it gets. if start is in the request, try passing it in explicitly with

dtml-var "_.DateTime(REQUEST.start)"

the source is always the best resource. zope's date time module is a dc thing. it has pretty
decent source documentation on the formats it will accept. its in
/lib/DateTime/DateTime.py

also regarding formating DateTime objects you might want to check the ZQR at the ZDP and also
the HowTo (search on date).

Cheers

Kapil

Skip Montanaro wrote:

> I have some objects that represent dates in ISO 8601 format, e.g.,
> "2000-04-21".  Within my DocumentTemplate I'd like to present those dates to
> users in a little nicer format.  With the attribute "start" containing the
> date I tried:
>
>     <dtml-var "_.DateTime(start).Date()">
>
> This yields a TypeError during rendering:
>
>     ...
>       File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_In.py, line 691, in renderwob
>         (Object: entries)
>       File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_Util.py, line 321, in eval
>         (Object: _.DateTime(start).Date())
>       File <string>, line 0, in ?
>     TypeError: illegal argument type for built-in operation
>
> I then tried:
>
>     <dtml-var "_.DateTime(start)">
>
> but got the same error.

> !!!!!!!!snip-snap!!!!!!!!!!!