Re: [web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-12 Thread Michael Beller
I've also been researching and experimenting ... I've come to the conclusion to only store utc dates (e.g., using utcnow) in the data base and then use .represent or other means to convert for display. Most notably, use the locale python library (http://docs.python.org/2/library/locale.html)

Re: [web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-12 Thread Michael Beller
this stores dates in UTC but displays date in alternate timezone. You can set the represent property based on a timezone stored in the users profile or derived from locale settings ... from pytz import timezone import pytz db.define_table('t_date', Field('f_name'), Field('f_datetime',

Re: [web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-12 Thread Alec Taylor
To keep things simple on the database side; how about making all times UTC? Then use JavaScript to impose timezone on the client-side. On Wed, Feb 13, 2013 at 2:20 PM, Michael Beller mjbel...@gmail.com wrote: this stores dates in UTC but displays date in alternate timezone. You can set the

Re: [web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-12 Thread Amit
Can we use represent callback in case of hugh number of rows(lets say 2 or more rows is there in db), will it not be causing to slow down the whole process, means, while converting utc time to target timezone's time one by one for each row and then displayed to UI using SQLFORM.grid()? Please

[web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-11 Thread newbie
On Tuesday, 12 February 2013 11:06:00 UTC+5:30, newbie wrote: Hi, I have a table x, with fields name,place,timezone_offset.And another table y ,having field 'servertime',which stores the current time of the server its fetching the values from.

Re: [web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-11 Thread Bruno Rocha
I am on mobile now and I cant ellaborate a good code example, but I can give you a hint. db.table.datefield.represent = lambda value, row : value.strftime(%Y/%m/%d) grid = SQLFORM.grid(db.table) so grid will use the represent callback to display the data. following this example you can do def