I'm seeing some bizarre behavior in the log vs in the display. I can't figure it out.
in settings.py:
TIME_ZONE = 'America/Chicago'
USE_TZ = True
in views.py:
local_timezone = pytz.timezone("America/Chicago")
blast = Blast.objects.get(id=blast_id)
blast_time = local_timezone.normalize(blast.date.astimezone(local_timezone))
print local_timezone
print blast.date
print blast_time
Output:
>>America/Chicago
>>2013-09-27 16:00:00+00:00
>>2013-09-27 11:00:00-05:00
All seems well.
Then in the template:
{{ blast.date|date:'D, d M h:i A e' }} {{ blast.date.tzinfo }}
({{ blast_time }} {{ blast_time.tzinfo }})
Renders as:
FRI, 27 SEP 11:00 AM CDT UTC
(SEPT. 27, 2013, 11 A.M. AMERICA/CHICAGO)
Note that the first line claims two different time zones, for reasons I can't fathom.
Changing the default time zone in settings.py to 'America/New_York' (but leaving the view as America/Chicago) results in:
>>2013-09-27 16:00:00+00:00
>>2013-09-27 11:00:00-05:00
And renders as:
FRI, 27 SEP 12:00 PM EDT UTC
(SEPT. 27, 2013, NOON AMERICA/CHICAGO)
Why does the render have a different value for the |date:'e'
and the .tzinfo
? And further, why is the blast_time
, which is converted to a different time zone, showing the same hour?