[Zope] Confused about manipulating dates in DTML

Skip Montanaro skip@mojam.com (Skip Montanaro)
Fri, 21 Apr 2000 14:57:55 -0500


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.

Table 2 in the DTML manual states:

    DateTime(): Create a DateTime object from zero or more arguments. See
    Appendix A, Date-time data on page 41.

Unfortunately, Appendix A only has this to say about creating DateTime
objects:

    From DTML, the special variable _ provides a method for constructing
    date-time values from strings and numeric data.

but gives no details about how to call the DateTime constructor.  It seems
to only list the attributes understood by DateTime objects.  It gives no
clues (that I can see) about how to actually create DateTime objects from
strings.

On the assumption that Zope's DateTime stuff is just a wrapper around
Marc-Andre Lemburg's mxDateTime I tried:

    <dtml-var "_.DateTimeFrom(start)">

thinking that constructor might just not have been documented.  Calling it
yielded an AttributeError for DateTimeFrom however.

What's a poor fella to do?

Thx,

-- 
Skip Montanaro | http://www.mojam.com/
skip@mojam.com | http://www.musi-cal.com/