datetime module and timezone

Chris Rebert clp2 at rebertia.com
Fri Feb 10 17:00:16 EST 2012


On Fri, Feb 10, 2012 at 1:25 PM, Olive <diolu at bigfoot.com> wrote:
> In the datetime module, it has support for a notion of timezone but is
> it possible to use one of the available timezone (I am on Linux). Linux
> has a notion of timezone (in my distribution, they are stored
> in /usr/share/zoneinfo). I would like to be able 1) to know the current
> timezone

time.tzname gives the zone names (plural due to DST); time.timezone
and time.altzone gives their UTC offsets.

> and 2) to be able to use the timezone available on the system.

You can use the name to look it up in pytz (http://pypi.python.org/pypi/pytz/ ).
And python-dateutil (http://labix.org/python-dateutil ) can apparently
parse zoneinfo files, if that's what you mean.

Cheers,
Chris



More information about the Python-list mailing list