Skip to content

Commit

Permalink
Merge pull request mozilla#2823 from safwanrahman/jinja
Browse files Browse the repository at this point in the history
[Bug 1259342] Fix datetimeformat jinja helpers
  • Loading branch information
Mike Cooper committed Mar 28, 2016
2 parents 71306fc + 92ef73e commit bdf2b48
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions kitsune/sumo/templatetags/jinja_helpers.py
Expand Up @@ -226,16 +226,17 @@ def datetimeformat(context, value, format='shortdatetime'):
else:
new_value = value

if 'timezone' not in request.session:
if request.user.is_authenticated():
try:
convert_tzinfo = (Profile.objects.get(user=request.user).timezone or
default_tzinfo)
except (Profile.DoesNotExist, AttributeError):
pass
request.session['timezone'] = convert_tzinfo
else:
convert_tzinfo = request.session['timezone']
if hasattr(request, 'session'):
if 'timezone' not in request.session:
if hasattr(request, 'user') and request.user.is_authenticated():
try:
convert_tzinfo = (Profile.objects.get(user=request.user).timezone or
default_tzinfo)
except (Profile.DoesNotExist, AttributeError):
pass
request.session['timezone'] = convert_tzinfo
else:
convert_tzinfo = request.session['timezone']

convert_value = new_value.astimezone(convert_tzinfo)
locale = _babel_locale(_contextual_locale(context))
Expand Down

0 comments on commit bdf2b48

Please sign in to comment.