I'm developing an application that will have users from different time 
zones.  The intent is to store everything in UTC and translate to user's 
timezone at display/edit time.  I started working on my own solution when I 
came across this post 
<https://groups.google.com/forum/#!searchin/web2py/IS_DATE$20timezone/web2py/jIEUIb8wxtg/rWe5g-IhCwAJ>which
 
seems to indicate that if you specify a timezone parameter to the IS_DATE() 
validator web2py will do all the timezone translation for you.

However every time I specify the timezone parameter to IS_DATE() I will get 
no dates validated no matter what

Without specifying a timezone it obviously works:
def test_date():
    db.define_table('test_table',Field('usr_comment'),Field('comment_date',
requires=IS_DATE('%Y-%m-%d')))
    form =SQLFORM.grid(db.test_table, create=True,editable=True, 
user_signature=False)
    return dict(form=form)


However this:
def test_date():
    db.define_table('test_table', Field('usr_comment'), Field('comment_date'
, requires=IS_DATE('%Y-%m-%d', timezone='America/Chicago')))
    form = SQLFORM.grid(db.test_table, create=True, editable=True, 
user_signature=False)
    return dict(form=form)

or even this:
def test_date():
    from pytz import timezone
    mytz = timezone('America/Chicago')
    db.define_table('test_table', Field('usr_comment'),Field('comment_date',
requires=IS_DATE('%Y-%m-%d', timezone=mytz)))
    form=SQLFORM.grid(db.test_table, create=True, editable=True,
user_signature=False)
    return dict(form=form)

Always tells me "Enter date as 1963-08-28" when submitting the form and 
never allows me to add/edit values (of course I'm entering dates as 
2015-10-25). 

Am I missing something or is there a bug with IS_DATE and timezone handling?

Thanks,
Julian

-- 
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/d/optout.

Reply via email to