On Tuesday, November 26, 2013 4:16:49 PM UTC-8, Jesse Ferguson wrote:
>
> Having a hard time figuring out this one and after googling my eyeballs 
> off Im here to beg for someone to throw me a bone, here is my code:
>
> MODEL:
>
> db.define_table('timecard_entry',
>                 Field('timecard', 'reference timecard', readable=False, 
> writable=False,),
>                 Field('company', 'reference company', label='Company'),
>                 Field('tc_start', 'time', requires = 
> IS_DATETIME(format=T('%H:%M %p')), label='Start'),          #Formatting 
> Does nothing
>                 Field('tc_stop', 'time', requires = 
> IS_DATETIME(format=T('%H:%M')), label='Stop'),                 #Here either
>

Do you really need the DB field to be hours and minutes, or would *displaying 
it* as hours and minutes be good enough?  Um, no, I guess ... you want to 
restrict the user to *entering* hours and minutes (and we see below that 
you want to further restrict what minutes are allowed.  But once the input 
is validated, the DB can hold a normal datetime field, right?

 

>                 Field('st' , 'double', label='ST'),
>                 Field('ot' , 'double', label='OT'),
>                 Field('dt' , 'double', label='DT'),
>                 Field('tc_classification' ,'string', 
> label='Classification'),
>                 auth.signature)
>
> CONTROLLER:
>
> def build_timecard():
>     id= request.args(0,cast=int)
>     timecard = db.timecard(id)
>     db.timecard_entry.timecard.default = timecard.id
>     form=SQLFORM(db.timecard_entry).process()
>     
> rows=db(db.timecard_entry.timecard==db.timecard(id)).select(orderby=db.timecard_entry.tc_start)
>     return locals()
>
> This Form Gives me 04:10:19 format for time... How do i change that to be 
> H:M p format such as 04:10 AM? Am I just missing something somewhere? Also 
> are there any validators I can use to have the time be only hours and half 
> hours accepted? for example 8:30 AM and 8:00 AM works but 8:15 AM does not? 
>
>
That doesn't sound like one of the validators that comes pre-cooked, but I 
think (says the newbie) that I've seen recent posts describing how to 
concatenate multiple validators on a field, and I'm going to make a 
baseless claim that writing your own to check that minutes is 0 or 30 will 
be easy, and then just concatenate it after the IS_DATETIME. 

Thanks in advance! and for the great community really learning a lot from 
> this forum and Massimo's videos
>

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to