Ok I found the problem. It turns out if I use IS_NOT_EMPTY(), the submitted
time field values get treated like a string rather than a datetime.time
object. Instead I changed requires to IS_TIME to get the intended result.
On Monday, August 29, 2016 at 10:00:21 PM UTC-4, 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.
>
>
--
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.