[Zope] Changing Python's Date/Time Input Format

Jens Vagelpohl jens at zope.com
Fri Nov 21 00:35:35 EST 2003


Instead of fighting windmills you should change your input form so that 
it minimizes user error. I would put selection widgets for 
day-of-month, month and maybe even year into that form instead of 
allowing people to type in some free-form date.

jens



On Nov 20, 2003, at 22:42, Julian Clark wrote:

> Hi All.
> I've got a minor issue with a form which takes a date and returns the 
> string
> date.
> I'm wanting the input format to be able to accept any of dd-mm-yy, dd 
> mon
> year, dd/mm/yyyy.
> Currently, it works for dd mon year, but it handles other input as 
> mm/dd/yy.
> (which is kind-of un-natural for those using this form)
>
> how should I modify this python script...
>
> today=DateTime(input)
> return today.strftime("%d %B %Y")
>
> ... to alert Zope that the incoming string will be always in the order 
> of dd
> mm yyyy?
>
>
> This is the traceback when the first tuple is not a valid month.
>
> <!--
>
> Traceback (innermost last):
>   File D:\Zope\2-3-3\lib\python\ZPublisher\Publish.py, line 223, in
> publish_module
>   File D:\Zope\2-3-3\lib\python\ZPublisher\Publish.py, line 187, in 
> publish
>   File D:\Zope\2-3-3\lib\python\Zope\__init__.py, line 221, in
> zpublisher_exception_hook
>     (Object: Traversable)
>   File D:\Zope\2-3-3\lib\python\ZPublisher\Publish.py, line 171, in 
> publish
>   File D:\Zope\2-3-3\lib\python\ZPublisher\mapply.py, line 160, in 
> mapply
>     (Object: template)
>   File D:\Zope\2-3-3\lib\python\ZPublisher\Publish.py, line 112, in
> call_object
>     (Object: template)
>   File D:\Zope\2-3-3\lib\python\OFS\DTMLMethod.py, line 189, in 
> __call__
>     (Object: template)
>   File D:\Zope\2-3-3\lib\python\DocumentTemplate\DT_String.py, line 
> 540, in
> __call__
>     (Object: template)
>   File D:\Zope\2-3-3\lib\python\DocumentTemplate\DT_Util.py, line 339, 
> in
> eval
>     (Object: stringdate(purc_date))
>     (Info: stringdate)
>   File &lt;string&gt;, line 0, in ?
>   File D:\Zope\Products\PythonMethod\PythonMethod.py, line 168, in 
> __call__
>     (Object: stringdate)
>     (Info: (('21/12/2003',), {}, None))
>   File &lt;string&gt;, line 2, in stringdate
>   File D:\Zope\2-3-3\lib\python\DateTime\DateTime.py, line 708, in 
> __init__
>   File D:\Zope\2-3-3\lib\python\DateTime\DateTime.py, line 1050, in 
> _parse
> Invalid Date Components: 21/12/2003
> -->
>
> Cheers,
>
> Julian Clark
>
>
>
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2355 bytes
Desc: not available
Url : http://lists.zope.org/pipermail/zope/attachments/20031121/73c4265a/smime.bin


More information about the Zope mailing list