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

Andreas Jung lists at andreas-jung.com
Fri Nov 21 01:30:42 EST 2003


This is implemented in Zope 2.7. Check doc/CHANGES.txt for details.

-aj

--On Freitag, 21. November 2003 11:42 Uhr +0800 Julian Clark 
<Julian.Clarke at b-online.com.au> 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 )







More information about the Zope mailing list