You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
this way, every event is now shown in the right day; however the date in the URL is a day ahead due to UTC storage, I guess using a slug solution would be a good approach.
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
inviews.py
was the next day. Realizing that this was a UTC/timezone issue I began investigating.Though
now()
fromdjango.utils.timezone
will display as local time if printed, the calls tonow().date()
seem to be lose the timezone and revert to UTC. Printnow().time()
for a very blatant example.I discovered that by importing
localtime()
fromdjango.utils.timezone
and wrapping eachnow()
call aslocaltime(now())
this solved the issue. There may be a prettier way but this does work, importing Django'sTIME_ZONE
fromsettings.py
and forcing.date()
and.time()
to remain timezone-aware.The text was updated successfully, but these errors were encountered: