Date Conversion in Zope

Bernard Yue bernie at 3captus.com
Tue Jun 3 13:21:16 EDT 2003


enrica dente wrote:

> Dear All,
>
> Does anyone know how to convert a date from format DD/MM/YYYY into 
> format YYYY/MM/DD using Python in Zope?

Short answer: Check Zope class DateTime

>
> I get a string date from an input box named EventDate which I then 
> need to pass to a <dtml-var> so that I can then convert its format. 
> The lines of code I've wrotten give the errors below.
>
>
> 1)
> <dtml-call "REQUEST.set('EventDate', fmt='%Y/%m/%d')">
> Error Type: TypeError
> Error Value: __setitem__() got an unexpected keyword argument 'fmt'
>
> 2)
> <dtml-call "REQUEST.set('event_date', 'EventDate.strftime(%d/%m/%Y)'">
> Expression (Python) Syntax error:
> unexpected EOF while parsing

Looks like you do not know what parameter does set() took.  Anyway
<dtml-call "REQUEST.set('event_date', EventDate.strftime(%d/%m/%Y)">
will work (you should not quote the second parameter of set() in case 2).

>
> The code I have found on Zope.org works ony  if you accept in the 
> imput box the american date format (MM,DD,YYYY) and not (DD,MM,YYYY).
>
> In the form:
> <input type="text" name="EventDate:date" size="25">
>
> In the DTML method:
> <dtml-call "REQUEST.set('EventDate', EventDate.strftime('%Y/%m/%d'))">
>
> How do I change EventDate into the (DD,MM,YYYY) format?
>
> Please help me.
> Regards
> Enrica
>
> _________________________________________________________________
> Stay in touch with absent friends - get MSN Messenger 
> http://www.msn.co.uk/messenger
>
>






More information about the Python-list mailing list