Unfortunately it doesn't look like IS_TIME has a format argument. That is 
odd.

from the stacktrace:

Field("start_time", "time", requires=IS_TIME(format="%I:%M")),
TypeError: __init__() got an unexpected keyword argument 'format'



On Tuesday, August 30, 2016 at 1:22:45 AM UTC-4, Dave S wrote:
>
>
>
> On Monday, August 29, 2016 at 7:00:21 PM UTC-7, H. Das wrote:
>>
>> Hello everyone,
>>
>> I defined a simple table with time fields like so:
>>
>> db.define_table("time_block",
>>     Field("start_time", "time", requires=IS_NOT_EMPTY()),
>>     Field("end_time", "time", requires=IS_NOT_EMPTY()),
>> )
>>
>> In jQuery I forced the time widget to show AM/PM like so:
>>
>> <script>
>>     jQuery.timeEntry.setDefaults({show24Hours: false, showSeconds: false});
>> </script>
>>
>> Now after I submit the form with the time say, 10:33PM, I get this error at 
>> the bottom of the traceback:
>>   File "C:\...\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1553, 
>> in parse_time
>>     time_items = list(map(int,str(value)[:8].strip().split(':')[:3]))
>> ValueError: invalid literal for int() with base 10: '33PM'
>>
>> It appears that AM/PM is not being recognized by dal? Is there another way 
>> to force AM/PM in time widgets instead of the default 24-hour? 
>>
>> My web2py version is Version 2.14.6-stable, I am using SQLite.
>>
>> Thanks.
>>
>>
>
> I think you need to modify your time validator:
>
> "This validator checks that a field value contains a valid datetime in the 
> specified format. It is good practice to specify the format using the 
> translation operator, in order to support different formats in different 
> locales."
> <URL:
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Date-and-time-validators
> >
> (The format string details are shown with IS_DATETIME(), but should apply 
> to IS_DATE() and IS_TIME().)
>
>  I think you can have that and the not-empty validator by using 
> requires=[...] (list notation).
>
> /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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to