I defined the following table:

db.define_table('OpeningHours',
    Field('nodeID','reference 
Node',default='',notnull=True,ondelete='CASCADE',writable=False,readable=False),
    Field('dayID','reference 
Day',default='',notnull=True,ondelete='RESTRICT'),
    Field('fromTime',type='time'),
    Field('toTime',type='time'),
    migrate=False)

db.OpeningHours.nodeID.requires=[IS_IN_DB(db,'Node.id','%(id)s',zero='select 
a value')]
db.OpeningHours.nodeID.represent=lambda nodeID, row: 
db(db.Organization.nodeID==nodeID).select().first().name
db.OpeningHours.dayID.requires=IS_IN_DB(db,'Day.id','%(name)s',orderby='Day.id',zero='select
 
a value')
db.OpeningHours.dayID.represent=lambda dayID, row: 
db(db.Day.id==dayID).select().first().name
db.OpeningHours.fromTime.requires=IS_TIME(format='%H:%M')
db.OpeningHours.toTime.requires=IS_TIME(format='%H:%M')


Since I only need the hours and minutes I thought I'd format the time like 
this:

IS_TIME(format='%H:%M')

... but that results in an error:


Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line 
205, in restricted
    exec ccode in environment
  File 
"/Library/Python/2.5/site-packages/web2py/applications/bootstrap/models/10_table_db.py"
 <http://127.0.0.1:8000/admin/default/edit/bootstrap/models/10_table_db.py>, 
line 603, in <module>
    db.OpeningHours.fromTime.requires=IS_TIME(format='%H:%M')
TypeError: __init__() got an unexpected keyword argument 'format'



Is there a way to format the time?

Kind regards,

Annet

Reply via email to