Horst,

Model:

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:

... 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:

... to use the date in a view:

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



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'))))


I hope I did not leave anything out, if so, let me know.


Kind regards,

Annet.








On May 22, 11:51 am, Horst Herb <my.list.subscripti...@gmail.com>
wrote:
> On Fri, May 22, 2009 at 7:20 PM,  <annet.verm...@gmail.com> wrote:
> > db.tablename.fieldname.requires=IS_NULL_OR(IS_DATE(str(T('%Y-%m-
> > %d'))))
>
> Thanks, that was what I was looking for!
>
> Another question: how / where can I (application wide) change the date
> format string so that all date entry and display conforms to it incl
> the date pickers? (eg '%d.%m.%Y')
>
> Horst
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to