Timezones. Ugh. The bane of every web programmer's existence. Let's make them easier!
For some reason, back when the language of the web was still being solidified, people forgot about timezones. The W3C remembered that not everybody speaks English, so they included the 'Accept-Language' HTTP Header, but apparently they never considered that users might not be in the same timezone as their server, so they forgot to include an 'Accept-Timezone' header. Since then, all web developers have been had the responsibility for figuring out the timezones of their users, rather than allowing their clients to do it automatically. This has resulted in a lot of horrible user experiences and misprinted time information over the years.
So, I've come up with an incredibly simple solution for Django developers who have to deal with timezones. It's called django-easy-timezones and, like the name implies, it's extremely simple to use. You can find django-easy-timezones on GitHub here.
Fundamentally, it is a Django middleware which uses the gratis MaxMind GeoIP database to find a user's location, figures out their timezone, and then stores it in their session context. Let's get started!
So just how easy is it?
django-easy-timezones is already published to pip, so all you have to do is..
pip install django-easy-timezones
or clone the git repository and copy the application into your project.
Then, add it to your project's INSTALLED_APPS like this: