tags:

views:

145

answers:

1

Hi all

I'm using toLocalizedTime to output a date, as below

<span tal:content="python:here.toLocalisedTime(date.get('start_date'))"/>

This outputs eg. 2007/08/02, I'm just curious as to how one would alter the output so that it reads 02/08/2007

I'm not having much luck finding much info on toLocalizedTime, if someone could even point me in the right direction I'd appreciate it.

Thanks in advance Ruth

A: 

This depends on whether you have English selected as the site language (Site Setup >> Language). If so, then the default settings are used. You can change the defaults by dropping down into the ZMI, then into 'portal_properties', then 'site_properties'. The fields to change are either 'localTimeFormat' or 'localLongTimeFormat' depending on whether you pass in 'long_format=1' to the toLocalisedTime function.

If on the other hand, you have translations set up, the format may instead be pulled from the translation file for the locale selected. I'm not sure what is the easy way to change the format in this case (other than switching the site back to English). I guess you can register your own translation file but I've never needed to do that so you're going to have to look up the details.

Date string formatting follows the Python rules (http://docs.python.org/library/time.html#time.strftime).


Perhaps even more detail than you need:

here.toLocalizedTime()

is defined in the plone browser view at...

CMFPlone/browser/ploneview.py

which looks up the 'translation_service' utility, to call its 'ulocalized_time' function, defined at...

CMFPlone/TranslationServiceTool.py

which itself calls the 'ulocalized_time' function defined at...

CMFPlone/i18nl10n.py

As always, you can learn interesting things by grepping the source code ;-)

Thats what I needed, Thanks a lot
Ruth