I
tried it in my application but I must be missing a step or something
because my time is NOT changing or maybe i'm just using it wrong!
Because
of different time zones I wanna convert my users time stamps from the
app hosters (
pythonanywhere.com) time (UTC) to my time (local time):
CODE:
Model (db.py):
# --------------------------------------------------------------------
#Detecting the usertime zone
#---------------------------------------------------------------------
is_timezone_unknown = (session.user_timezone is None)
user_timezone = session.user_timezone or 'UTC'
Model (Application DB)
datetime_validator = IS_DATETIME(timezone=pytz.timezone(user_timezone), format=DATE_FORMAT)
Controller:
def set_timezone():
"""Ajax call to set the timezone information for the session."""
tz_name = request.vars.name
from pytz import all_timezones_set
if tz_name in all_timezones_set:
session.user_timezone = tz_name
View (Somewhere in the Layout):
{{if is_timezone_unknown:}}
<script src="{{=URL('static', 'js/jstz.min.js')}}"></script>
<script>
$(function() {
var tz_name = jstz.determine();
$.get("{{=URL('default', 'set_timezone')}}", tz_name);
});
</script>
{{pass}}
I wanna believe this is how this solution is used but I am not getting results!
Please assist;
Regards;
Mostwanted