[Zope] formatting a date string
Jeff Hoffman
jeff.hoffman@goingv.com
Sun, 5 Mar 2000 12:27:13 -0500 (EST)
On Sun, 5 Mar 2000, Graham Chiu wrote:
> >Okay, it's simple enough -
> >
> ><dtml-call "REQUEST.set('mydate',_.DateTime('2000/12/31'))">
> >
> >creates the date object I need to then reformat it.
>
> Oops, spoke too soon. Spent the last few hours trying to suss this out
> without any progress :-(
>
> I have a variable called START returned by a sqlquery
>
> <dtml-call "REQUEST.set('startdate',START)">
> start is <dtml-var startdate>
Is START being returned as a string, or as a DateTime from your query? If
it's being returned as a string, you need:
<dtml-call "REQUEST.set('startdate', _.DateTime(START))">
> and that's okay
>
> <dtml-call "REQUEST.set('month',_.DateTime(startdate).aMonth">
>
> That, and variations of the same, dies with
>
> Error Type: TypeError
> Error Value: __div__ nor __rdiv__ defined for these operands
aMonth() is a method, not an attribute. You need to _call_ it, i.e.:
<dtml-call "REQUEST.set('month', _.DateTime(startdate).aMonth())">
or, if startdate is already a DateTime:
<dtml-call "REQUEST.set('month', startdate.aMonth())">
Another way of doing this, however, is something like the following:
<dtml-call "REQUEST.set('mydate', _.DateTime('2000/12/31'))">
<dtml-var mydate fmt=dd>-<dtml-var mydate fmt=aMonth>-<dtml-var mydate
fmt=year>
Voila.
> Why is that these simple little things are so difficult in Zope?
The above does not seem too difficult to me. You made a few simple
mistakes, that's all.
--Jeff
---
Jeff K. Hoffman 704.849.0731 x108
Chief Technology Officer mailto:jeff@goingv.com
Going Virtual, L.L.C. http://www.goingv.com/