[Zope] formatting a date string

Jeff Hoffman jeff.hoffman@goingv.com
Tue, 7 Mar 2000 09:44:29 -0500 (EST)


On Tue, 7 Mar 2000, Graham Chiu wrote:

> I'm still having difficulty with this.
> 
> I want to add a date to a character string ( dated user comments ) to
> store into a sqltable.
> 
> <dtml-call "REQUEST.set('CurrentDate', ZopeTime().Date)">

This is the same problem as last time. You must CALL the Date method, not
just reference it. The above line should read:

  <dtml-call "REQUEST.set('CurrentDate', ZopeTime().Date()">

Note the use of parens on Date().

Try it for yourself by putting the following in a DTML Method:

  <dtml-var expr="ZopeTime().Date">

You get:
  
  <method DateTime.Date of DateTime instance at 568eb0>

if you do a View | Source in your browser.

> The docs say that this returns a date string ( as opposed to a date
> object? )

It does, if you CALL it.

> <dtml-call "REQUEST.set('mystring', 'date: '+CurrentDate)">
> 
> produces this error
> 
> Error Type: TypeError
> Error Value: illegal argument type for built-in operation

Here is some code that works:

  <dtml-call "REQUEST.set('CurrentDate', ZopeTime().Date())">
  <dtml-call "REQUEST.set('mystring', 'date: ' + CurrentDate)">
  <dtml-var mystring>

> And if I try this
> 
> <dtml-call "REQUEST.set('mystring', 'date: '+_.str(CurrentDate))">

Again, you've never set CurrentDate correctly. View the source of the page
that comes back and you will see the problem.

> mystring is then 'date:'

Hope this helps.

--Jeff

---
Jeff K. Hoffman                                         704.849.0731 x108
Chief Technology Officer                                mailto:jeff@goingv.com
Going Virtual, L.L.C.                                   http://www.goingv.com/