Hi Mirek,

Here's an excerpt of my log that might be helpful:

Formatting date

Model file:

T.force('en-de')  ## en-de is a language file you'll create below

In the table definition:

SQLField('fieldname', type='date')

... a validator on this field which reads like:

db.tablename.fieldname.requires=IS_NULL_OR(IS_DATE(str(T('%Y-%m-
%d'))))

Languages file:

... create a language file e.g. en-de.py and edit the dates:

Original                                Translation
%Y-%m-%d                                %d-%m-%Y
%Y-%m-%d %H:%M:%S               %d-%m-%Y %H:%M:%S

Click update.

Views file:

... to use the date in a view:

{{=db.tablename.fieldname.formatter(tablename.fieldname)}}

If you use form_factory to create a custom form, the code in the
controller should read:

SQLField('fieldname',type='date',requires=IS_DATE(str(T('%Y-%m-
%d'))))

Kind regards,

Annet.

Reply via email to