The Python timezone library pytz has one missing feature. There is no way to get the computers local timezone, unless you know the name of it, and figuring out the name is not always possible on some unix distros. And on windows, the timezone names are competely different from the ones pytz uses. dateutil.tz has support for it, but pytz does not.
tzlocal fixes that, by giving you a simple method get_localzone() that will return your local computers timezone as a tzinfo object, for use with pytz as normal.
Usage is simply:
>>> from tzlocal import get_localzone >>> tz = get_localzone()
Any operating system with a zoneinfo file in /etc/localtime is supported, and also Windows. It needs widespread testing on many different distributions and different versions of Windows, so if you want to help, install it and test it on your computer!
Filed under: calendaring, plone, python, python3 Tagged: pytz, timezones
