#26711: Aware datetimes rendered through templates are changed to TIME_ZONE
---------------------------------+--------------------
     Reporter:  aptiko           |      Owner:  nobody
         Type:  Bug              |     Status:  new
    Component:  Template system  |    Version:  1.9
     Severity:  Normal           |   Keywords:
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  0                |      UI/UX:  0
---------------------------------+--------------------
 Start a new project with {{{django-admin startproject}}}, then start a
 shell with {{{./manage.py shell}}} and execute these commands:

 {{{
 from datetime import datetime
 import sys

 from django.template import Context, Template

 import pytz

 # Set adatetime to 2015-10-03 02:00 EEST (+0300)
 athens = pytz.timezone('Europe/Athens')
 adatetime = athens.localize(datetime(2015, 10, 3, 2, 0))

 # Render that date in a template
 template = Template(
     'Take note of this date: {{ adatetime|date:"Y-m-d H:i e (O)" }}')
 result = template.render(Context({'adatetime': adatetime}))
 sys.stdout.write(result)
 }}}

 **Result:** `2015-10-02 23:00 UTC (+0000)`

 **Expected:** `2015-10-03 02:00 EEST (+0300)`

 These are actually the same time displayed in different time zones. Django
 chooses to display the time in the `TIME_ZONE` setting. I thought it would
 be more logical to leave an aware datetime untouched.

 If this behavior is correct: How am I going to do what I want, which is to
 render the aware datetime in its own time zone?

--
Ticket URL: <https://code.djangoproject.com/ticket/26711>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.600d4fc2f2844de9fdd8618d5943ee68%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to