beware that the offset is NOT the same thing as the timezone (DST adds 
another layer of complexity)

On Monday, March 25, 2013 6:40:26 PM UTC+1, Derek wrote:
>
> I'd rather store the dates in the database in local time with the offset 
> stored (ie take out the [:19]).
>
> On Sunday, March 17, 2013 7:31:24 PM UTC-7, Massimo Di Pierro wrote:
>>
>> I was looking at code to detect the user timezone and store dates 
>> consistently in UTC format.
>> I made some changes in trunk to handle this. I could use some help 
>> testing.
>>
>> 1) In the header of your layout.html add:
>>
>>  {{if not session.timezone:}}
>>   <script>
>>     
>> jQuery(function(){jQuery.post('{{=URL('default','set_timezone')}}',{timezone:(new
>>  
>> Date()).getTimezoneOffset()});});
>>   </script>
>> {{pass}}
>>
>> 2) in the default controller:
>>
>> def set_timezone():
>>     session.timezone = int(request.vars.timezone)/60
>>
>> 3) Use the new timezone attribute of validators in trunk:
>>
>>    Field('birthday','datetime',requires = 
>> IS_DATETIME(timezone=session.timezone)
>>
>> Does it work for you? Suggestions for improvement?
>>
>> Massimo
>>
>

-- 

--- 
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