Description
I was tweaking calendarium 1.3.4 today to work with my Django 1.11 site and I noticed that, after 5pm PST, it was already saying that "today" was tomorrow. As in, the day for which current = True
in views.py
was the next day. Realizing that this was a UTC/timezone issue I began investigating.
Though now()
from django.utils.timezone
will display as local time if printed, the calls to now().date()
seem to be lose the timezone and revert to UTC. Print now().time()
for a very blatant example.
I discovered that by importing localtime()
from django.utils.timezone
and wrapping each now()
call as localtime(now())
this solved the issue. There may be a prettier way but this does work, importing Django's TIME_ZONE
from settings.py
and forcing .date()
and .time()
to remain timezone-aware.