[Zope] property:date
J. Cameron Cooper
jccooper@rice.edu
Tue, 14 Aug 2001 15:36:47 -0500
>
>
>The idea was:
>
>1. go to the management GUI and add a my_date property to the ZClass
>2. use a format string as the value for the property
>3. use name="mydate:date" in the relevant form
>4. let Zope do the conversion ...
>
>The reality is:
>
>I cannot even accomplish step 2!
>Whatever I enter in the value field for the property for the ZClass (apart from an actual date which is readly converted in yyyy/mm/dd format), Zope complains about an 'Invalid Date-Time String'.
>
How I have done it:
1. Submit your date as a string.
2. Create a Python Script to convert a string to a DateTime object. This
could be as easy as 'return DateTime(str)', which will understand a
great number of formats. But I think the format you want will be
understood as the US mm/dd/[yy]yy, so you may have to do a little work.
See Zope Help > API Reference > DateTime in the Zope Help System.
3. In whatever the form is submitted to call above script and store the
results. This property can then be used as a DateTime in display:
'<dtml-var "timeProp.ISO()">
You could also have your script return a canonical string or a floating
point number representation of the time, if you'd rather store that.
Or you could use a Python Script to preprocess your REQUEST and convert
your string to something DateTime understands (ISO) and then hand it to
a method that stores it in a 'date' property.
--jcc
(space-time)