[Zope] datetime format
Andreas Jung
lists at zopyx.com
Mon Mar 5 04:41:48 EST 2007
--On 5. März 2007 10:09:55 +0100 Tino Wildenhain <tino at wildenhain.de>
wrote:
> Andreas Jung schrieb:
>>
>>
>> --On 5. März 2007 07:12:23 +0100 Tino Wildenhain <tino at wildenhain.de>
>> wrote:
>>
>>> Garry Saddington schrieb:
>>>> I have 'datetime-format international' set in zope.conf but the date
>>>> output is still rendered in the format (y,m,d) when using ZopeTime or
>>>> when returning dates from python scripts. How can I change this
>>>> behaviour? My server config is:
>>>
>>> Well what you see is not "the date" but one representation of the
>>> DateTime object. You can use the strftime() method to render your
>>> date object to string in any form you want. This should also
>>> answer your question on postgres list. Your database adaptor
>>> turns database types into zope types.
>>
>> In addition: SQL also provides support converting a date type of the
>> database into a string. See TO_DATE(...).
>
> Yes it does but its to_char() not to_date() ;)
Yup.
>And I would not
> use it much because you loose all type information and the
> ability to sort accordingly and calculate with the values.
>
> Better format them just for output - which would be in
> python code.
>
It depends on the usecase..if you don't have to deal with different
date format it is handy to convert it on the RDBMS level..otherwise
you have to write something like
<span tal:content="python: row.mydate.strftime(fmtstring)" />
instead of
<span tal:content="row/mydate" />
-aj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20070305/e08aa1f4/attachment.bin
More information about the Zope
mailing list