[web2py] Timezone

2020-04-05 Thread Gaƫl Princivalle
Hello all.

How can I set the timezone of my Web2py app?

Adding it in the httpd.conf Apche2 file don't change it (also after stop 
and start):
SetEnv TZ Europe/Rome

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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8c998a79-0984-411d-b531-7606f9bbfd96%40googlegroups.com.


[web2py] Timezone handling

2014-05-06 Thread Michael Beller
I found many discussions in the forums on handling timezones.  Most paths 
lead to Niphlod's timezone plugin (thank you!).  But most of the comments 
and documentation surrounding that plugin didn't address standardizing on 
UTC throughout the app, enabling timezone handling for auth.signatures, and 
the function of the timezone parameter in the IS_DATETIME validator.

Here is what I have so far to bring these all together - all feedback 
appreciated ...

Start by adding the timezone plugin to your app: 
https://github.com/niphlod/w2p_timezone_plugin

Add "request.now = request.utcnow" at the top of db.py.  This sets all 
internal datetimes to UTC.  I found one comment about potential session 
handling prior to the first model executing but I haven't run into any 
problems.  This assures that all dates stored in the database and elsewhere 
are UTC.

Then import pytz.  This seems like the best python timezone library.  There 
are discussions in the developers group about not making this a dependency 
(and Massimo cited some viable alternatives).  Niphlod's plugin requires it.

If you want all your auth.signatures to follow the same rules as other 
datetime fields (and the datetime fields in auth_event and auth_cas) then 
add these five lines before any calls to define_table that include 
auth.signature:

user_timezone = session.plugin_timezone_tz or 'UTC'
db.auth_event.time_stamp.requires = IS_DATETIME(timezone=pytz.timezone(
user_timezone))
db.auth_cas.created_on.requires = IS_DATETIME(timezone=pytz.timezone(
user_timezone))
auth.signature.created_on.requires = IS_DATETIME(timezone=pytz.timezone(
user_timezone))
auth.signature.modified_on.requires = IS_DATETIME(timezone=pytz.timezone(
user_timezone))

session.plugin_timezone_tz is handled by the timezone plugin.

I couldn't find any documentation on the timezone parameter for the 
IS_DATETIME validator.  This parameter translates datetime's to and from 
UTC, i.e., the validator will validate and then translate a date entered on 
a form from the user_timezone to UTC and performs the reverse operation 
when retrieving the datetime from the database for display on a form.  All 
dates are stored in UTC.

To display the timezone in grids and views, modify the languages file and 
add "%Z" to the end of the datetime string translation, 
i.e.,for %Y-%m-%d %H:%M:%S enter %Y-%m-%d %H:%M:%S %Z (I'm having a problem 
with this in edit forms which I think is a bug in the widget).

Then I follow the instructions for the timezone plugin to detect the users 
timezone, set the session variable.

I think there is some overlap in some of the string formatting for the 
timezone in the plugin with the languages translation but I haven't found a 
problem yet (I'm not sure the pluging uses the translations).

Does this look right?


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


[web2py] Timezone

2012-09-12 Thread Rod Watkins
I have a question about timezones. What is the best way to handle datetimes 
entered by users. Since they will enter a datetime in their local timezone, 
what is the best way to transform that to a UTC datetime value before 
inserting it into the database?

Thanks
Rod

-- 





[web2py] timezone support in dal, assumes local time is gmt time

2012-08-21 Thread Tim Michelsen
Could you explain this functionality, its application and settings?

https://github.com/web2py/web2py/commit/ed485d38abe90e2c8f6578252d69fa9ebd4b98c1

-- 





[web2py] Timezone

2010-05-17 Thread Chris
Hi,
Is there a way to set the timezone application wide so that datetimes
are displayed correctly where I am and not what the server is set as?

Chris