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: Zope Version (Zope 2.9.0, python 2.4.2, win32) Python Version 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] System Platform win32 Regards Garry
--On 4. März 2007 12:45:20 +0000 Garry Saddington <garry@schoolteachers.co.uk> wrote:
I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d)
Reading helps.. # Directive: datetime-format # # Description: # Set this variable either to "us" or "international" to force the # DateTime module to parse date strings either with # month-before-days-before-year ("us") or # days-before-month-before-year ("international"). The default # behaviour of DateTime (when this setting is left unset) is to # parse dates as US dates. # The documentation only speaks for parsing... -aj
On Sunday 04 March 2007 13:32, Andreas Jung wrote:
--On 4. März 2007 12:45:20 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d)
Reading helps.. Yes, indeed it does, how did you suppose I knew how to set the format in the first place. I presume that I will have to explicitly format the date output then, or is there a way for Zope to automatically do this?
Garry
--On 4. März 2007 15:57:44 +0000 Garry Saddington <garry@schoolteachers.co.uk> wrote:
On Sunday 04 March 2007 13:32, Andreas Jung wrote:
--On 4. März 2007 12:45:20 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d)
Reading helps.. Yes, indeed it does, how did you suppose I knew how to set the format in the first place.
DateTime has a documentation and there is strftime() method to provide support for custom format. The *string* representation of a DateTIme instance as returned through the __str__() is unlikely a good choice for application level usage. -aj
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. Regards Tino
--On 5. März 2007 07:12:23 +0100 Tino Wildenhain <tino@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(...). -aj
Andreas Jung schrieb:
--On 5. März 2007 07:12:23 +0100 Tino Wildenhain <tino@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() ;) 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. Regards Tino
--On 5. März 2007 10:09:55 +0100 Tino Wildenhain <tino@wildenhain.de> wrote:
Andreas Jung schrieb:
--On 5. März 2007 07:12:23 +0100 Tino Wildenhain <tino@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
Andreas Jung schrieb:
...
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)" />
No, you would do that in your formatter class or at least in the python script preparing the values for the template. Regards Tino :-)
participants (3)
-
Andreas Jung -
Garry Saddington -
Tino Wildenhain