> I have two more questions though:
>
> In the interface the time displays like 15:00:00 how do I get it do
> display in the format: 15:00?

Changing your widget to the following will change the way the time
appears in forms:

def timeplain(field,value):
        if value == None:
            value = ''
        elif 'strftime' in dir
(value):                                        # These are
            value = value.strftime('%H:%M')                          #
the
 
else:
# changed
            value = str
(value)                                               # lines
        id = '%s_%s' % (field._tablename, field.name)
        return INPUT(
            _type='text',
            _id=id,
            _class='time_plain',
            _name=field.name,
            value=value,
            requires=field.requires,
            )

In other places where you generate output you can use strftime('%H:
%M') to format e.g.

        timetable=db((db.timetable.day==weekday)&
(db.timetable.time>=nowtime)).select
(db.timetable.ALL,orderby=db.timetable.time,limitby=(0,6))

in view
   {{=timetable.time.strftime("%H:%M")}}

More info about strftime in documentation 
http://docs.python.org/library/time.html

>
> How do I validate the field to have the correct format?

associate the IS_TIME() validator with the field, so I put:

db.define_table('timetable',
   db.Field('day', 'integer'),
   db.Field('time', 'time', widget=timeplain, requires=IS_TIME()))

Do you have the web2py book? The PDF version is very reasonably priced
and extremely good. http://www.lulu.com/content/4968879 The codebase
has developed since it was published but because of web2py's backward
compatibility, everything in the book is still valid. Documentation on
the newer features is available on the web site e.g.
http://www.scribd.com/doc/16085263/web2py-slides-version-163

> ... to work. Hence, my "mucking about with times in string format" ;-)
>
Sorry if I was a little rude. I was just quite excited to see a
question on the mailing list that I thought I could actually answer!

Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to