/usr/lib/python2.6/site-packages
NameSizeModeActions
appdirs-1.4.0.dist-info/-0755rm
argparse-1.4.0.dist-info/-0755rm
babel/-0755rm
Babel-2.1.1.dist-info/-0755rm
Babel-2.3.4.dist-info/-0755rm
backports/-0755rm
backports.ssl_match_hostname-3.4.0.2-py2.6.egg-info/-0755rm
boto/-0755rm
boto-2.34.0-py2.6.egg-info/-0755rm
cffi-1.6.0-py2.6-linux-x86_64.egg/-0755rm
chardet/-0755rm
chardet-2.2.1-py2.6.egg-info/-0755rm
cinderclient/-0755rm
clcommon/-0755rm
cliff/-0755rm
cliff-1.15.0.dist-info/-0755rm
cliff-2.0.0.dist-info/-0755rm
clifftablib/-0755rm
cliff_tablib-1.1-py2.6.egg-info/-0755rm
cloudinit/-0755rm
cloud_init-0.7.5-py2.6.egg-info/-0755rm
cmd2-0.6.8-py2.6.egg-info/-0755rm
concurrent/-0755rm
cryptography-1.3.1-py2.6-linux-x86_64.egg/-0755rm
dateutil/-0755rm
dbus/-0755rm
debtcollector/-0755rm
debtcollector-0.8.0.dist-info/-0755rm
debtcollector-1.3.0.dist-info/-0755rm
decorator-4.0.9.dist-info/-0755rm
dict-0.0.5-py2.6.egg-info/-0755rm
distribute-0.6.10-py2.6.egg-info/-0755rm
dns/-0755rm
enum/-0755rm
enum34-1.0.4-py2.6.egg-info/-0755rm
enum34-1.1.3-py2.6.egg/-0755rm
funcsigs/-0755rm
funcsigs-1.0.2.dist-info/-0755rm
futures-3.0.3.dist-info/-0755rm
futures-3.0.5.dist-info/-0755rm
get-0.0.7-py2.6.egg-info/-0755rm
glanceclient/-0755rm
idna/-0755rm
idna-2.0.dist-info/-0755rm
idna-2.1-py2.6.egg/-0755rm
iniparse/-0755rm
iotop/-0755rm
iotop-0.3.2-py2.6.egg-info/-0755rm
ipaddress-1.0.14-py2.6.egg-info/-0755rm
ipaddress-1.0.16-py2.6.egg/-0755rm
iso8601/-0755rm
iso8601-0.1.10-py2.6.egg-info/-0755rm
iso8601-0.1.11.dist-info/-0755rm
jsonpatch-1.2-py2.6.egg-info/-0755rm
jsonpatch-1.11.dist-info/-0755rm
jsonpatch-1.13.dist-info/-0755rm
jsonpointer-1.9.dist-info/-0755rm
jsonpointer-1.10.dist-info/-0755rm
jsonschema/-0755rm
jsonschema-2.5.1.dist-info/-0755rm
keystoneauth1/-0755rm
keystoneauth1-1.1.0.dist-info/-0755rm
keystoneauth1-2.6.0.dist-info/-0755rm
keystoneclient/-0755rm
markdown/-0755rm
monotonic-0.4-py2.6.egg-info/-0755rm
monotonic-1.1.dist-info/-0755rm
ndg/-0755rm
ndg_httpsclient-0.4.0-py2.6.egg-info/-0755rm
netaddr/-0755rm
netaddr-0.7.18.dist-info/-0755rm
neutronclient/-0755rm
nose/-0755rm
nose-0.10.4-py2.6.egg-info/-0755rm
novaclient/-0755rm
oauth/-0755rm
oauth-1.0.1-py2.6.egg-info/-0755rm
openstack/-0755rm
openstackclient/-0755rm
openstacksdk-0.8.5.dist-info/-0755rm
oslo.config-2.4.0.dist-info/-0755rm
oslo.config-3.9.0.dist-info/-0755rm
oslo.i18n-2.6.0.dist-info/-0755rm
oslo.i18n-3.6.0.dist-info/-0755rm
oslo.serialization-1.9.0.dist-info/-0755rm
oslo.serialization-2.4.0.dist-info/-0755rm
oslo.utils-2.5.0.dist-info/-0755rm
oslo.utils-3.8.0.dist-info/-0755rm
oslo_config/-0755rm
oslo_i18n/-0755rm
oslo_serialization/-0755rm
oslo_utils/-0755rm
os_client_config/-0755rm
os_client_config-1.8.1.dist-info/-0755rm
os_client_config-1.17.0.dist-info/-0755rm
pbr/-0755rm
pbr-1.8.0.dist-info/-0755rm
pbr-1.9.1.dist-info/-0755rm
pip-7.1.2-py2.6.egg/-0755rm
pip-8.1.1-py2.6.egg/-0755rm
pkg_resources/-0755rm
positional/-0755rm
positional-1.1.0-py2.6.egg-info/-0755rm
post-0.0.5-py2.6.egg-info/-0755rm
prettytable-0.7.2-py2.6.egg-info/-0755rm
public-0.0.0-py2.6.egg-info/-0755rm
pyasn1/-0755rm
pyasn1-0.0.12a-py2.6.egg-info/-0755rm
pyasn1-0.1.9-py2.6.egg/-0755rm
pyasn1-0.1.9.dist-info/-0755rm
pycparser/-0755rm
pycparser-2.14-py2.6.egg/-0755rm
pycparser-2.14-py2.6.egg-info/-0755rm
pygments/-0755rm
Pygments-1.1.1-py2.6.egg-info/-0755rm
pyparsing-2.0.3.dist-info/-0755rm
pyparsing-2.1.1.dist-info/-0755rm
python_cinderclient-1.4.0.dist-info/-0755rm
python_cinderclient-1.6.0.dist-info/-0755rm
python_dateutil-1.4.1-py2.6.egg-info/-0755rm
python_glanceclient-1.1.0.dist-info/-0755rm
python_glanceclient-2.0.0.dist-info/-0755rm
python_keystoneclient-1.7.1.dist-info/-0755rm
python_keystoneclient-2.3.1.dist-info/-0755rm
python_neutronclient-3.1.0.dist-info/-0755rm
python_novaclient-2.31.0.dist-info/-0755rm
python_novaclient-4.0.0.dist-info/-0755rm
python_openstackclient-1.7.1.dist-info/-0755rm
python_openstackclient-2.4.0.dist-info/-0755rm
python_swiftclient-2.6.0.dist-info/-0755rm
python_swiftclient-3.0.0.dist-info/-0755rm
pytz/-0755rm
pytz-2015.6.dist-info/-0755rm
pytz-2016.4.dist-info/-0755rm
pyzor-1.0.0-py2.6.egg/-0755rm
query_string-0.0.5-py2.6.egg-info/-0755rm
repoze/-0755rm
repoze.lru-0.6-py2.6.egg-info/-0755rm
request-0.0.5-py2.6.egg-info/-0755rm
requests/-0755rm
requests-2.7.0.dist-info/-0755rm
requests-2.9.1.dist-info/-0755rm
requestsexceptions/-0755rm
requestsexceptions-1.1.3.dist-info/-0755rm
rhn/-0755rm
rpmUtils/-0755rm
rsa/-0755rm
rsa-3.4.2-py2.6.egg-info/-0755rm
self-0.0.5-py2.6.egg-info/-0755rm
setools/-0755rm
setuptools/-0755rm
setuptools-20.10.1.dist-info/-0755rm
six-1.9.0.dist-info/-0755rm
six-1.10.0.dist-info/-0755rm
sos/-0755rm
stevedore/-0755rm
stevedore-1.8.0.dist-info/-0755rm
stevedore-1.12.0.dist-info/-0755rm
supervisor/-0755rm
swiftclient/-0755rm
tablib/-0755rm
tablib-0.10.0.dist-info/-0755rm
unicodecsv/-0755rm
unicodecsv-0.14.1-py2.6.egg-info/-0755rm
urlgrabber/-0755rm
urllib3/-0755rm
urllib3-1.10.2-py2.6.egg-info/-0755rm
urllib3-1.12.dist-info/-0755rm
urllib3-1.15.1.dist-info/-0755rm
warlock/-0755rm
warlock-1.1.0-py2.6.egg-info/-0755rm
warlock-1.2.0-py2.6.egg-info/-0755rm
yum/-0755rm
yumutils/-0755rm
appdirs.py223740755editdlrm
appdirs.pyc206650644editdlrm
argparse.py892140644editdlrm
argparse.pyc668150644editdlrm
argparse.pyo664910644editdlrm
chardet-2.0.1-py2.6.egg-info16050644editdlrm
clsudo.py129530644editdlrm
clsudo.pyc113920644editdlrm
clsudo.pyo113920644editdlrm
cmd2.py650690644editdlrm
cmd2.pyc650190644editdlrm
configobj-4.6.0-py2.6.egg-info3120644editdlrm
configobj.py864470644editdlrm
configobj.pyc664120644editdlrm
configobj.pyo664120644editdlrm
dbus_bindings.py330644editdlrm
dbus_bindings.pyc1850644editdlrm
dbus_bindings.pyo1850644editdlrm
decorator.py157750644editdlrm
decorator.pyc144850644editdlrm
dict.py22390644editdlrm
dnspython-1.11.1-py2.6.egg-info12800644editdlrm
easy-install.pth2760644editdlrm
easy_install.py1260644editdlrm
easy_install.pyc3170644editdlrm
easy_install.pyo3170644editdlrm
get.py3220644editdlrm
hwdata.py81420644editdlrm
hwdata.pyc62830644editdlrm
hwdata.pyo62830644editdlrm
iniparse-0.3.1-py2.6.egg-info10850644editdlrm
ipaddress.py796590644editdlrm
ipaddress.pyc759000644editdlrm
jsonpatch.py159460644editdlrm
jsonpatch.pyc174810644editdlrm
jsonpatch.pyo172770644editdlrm
jsonpointer-1.0-py2.6.egg-info3020644editdlrm
jsonpointer.py66100644editdlrm
jsonpointer.pyc63680644editdlrm
jsonpointer.pyo63680644editdlrm
libproxy.py43300644editdlrm
libproxy.pyc39900644editdlrm
libproxy.pyo39900644editdlrm
lprettytable.py238490755editdlrm
lprettytable.pyc196190644editdlrm
lprettytable.pyo194720644editdlrm
Markdown-2.0.1-py2.6.egg-info13400644editdlrm
monotonic.py53450644editdlrm
monotonic.pyc54790644editdlrm
ndg_httpsclient-0.4.0-py2.6-nspkg.pth2960644editdlrm
ordereddict-1.1-py2.6.egg-info1830644editdlrm
ordereddict-1.2-py2.6.egg-info1830644editdlrm
ordereddict.py42210644editdlrm
ordereddict.pyc44210644editdlrm
ordereddict.pyo44210644editdlrm
pciutils-2.3.5-py2.6.egg-info2420644editdlrm
pkg_resources.py881960644editdlrm
pkg_resources.pyc928750644editdlrm
pkg_resources.pyo928750644editdlrm
post.py2260644editdlrm
prettytable.py542040644editdlrm
prettytable.pyc522520644editdlrm
prettytable.pyo512660644editdlrm
public.py46350644editdlrm
pyOpenSSL-0.15.1-py2.6.egg2357360644editdlrm
pyOpenSSL-16.0.0-py2.6.egg943080644editdlrm
pyparsing.py1582560644editdlrm
pyparsing.pyc1578590644editdlrm
pytz-2010h-py2.6.egg-info225770644editdlrm
query_string.py8400644editdlrm
README1190644editdlrm
repoze.lru-0.6-py2.6-nspkg.pth3070644editdlrm
request.py2070644editdlrm
requests-2.6.0-py2.6.egg-info403570644editdlrm
rhnlib-2.5.22-py2.6.egg-info3390644editdlrm
secureio.py92220644editdlrm
secureio.pyc47210644editdlrm
secureio.pyo47210644editdlrm
self.py7280644editdlrm
setuptools-0.6c11-py2.6.egg-info1440644editdlrm
setuptools-18.3.2-py2.6.egg3590330755editdlrm
setuptools-20.9.0-py2.6.egg4728320644editdlrm
setuptools.pth340644editdlrm
site.py23620644editdlrm
site.pyc17710644editdlrm
site.pyo17710644editdlrm
six.py296640644editdlrm
six.pyc293300644editdlrm
six.pyo269110644editdlrm
supervisor-2.1-py2.6.egg-info7970644editdlrm
urlgrabber-3.9.1-py2.6.egg-info22850644editdlrm
validate.py467680644editdlrm
validate.pyc473840644editdlrm
validate.pyo473840644editdlrm
Edit: /usr/lib/python2.6/site-packages/pytz-2010h-py2.6.egg-info (22577B)
Metadata-Version: 1.0 Name: pytz Version: 2010h Summary: World timezone definitions, modern and historical Home-page: http://pytz.sourceforge.net Author: Stuart Bishop Author-email: stuart@stuartbishop.net License: MIT Download-URL: http://pypi.python.org/pypi/pytz Description: pytz - World Timezone Definitions for Python ============================================ :Author: Stuart Bishop Introduction ~~~~~~~~~~~~ pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.3 or higher. It also solves the issue of ambiguous times at the end of daylight savings, which you can read more about in the Python Library Reference (``datetime.tzinfo``). Amost all of the Olson timezones are supported. Note that this library differs from the documented Python API for tzinfo implementations; if you want to create local wallclock times you need to use the ``localize()`` method documented in this document. In addition, if you perform date arithmetic on local times that cross DST boundaries, the results may be in an incorrect timezone (ie. subtract 1 minute from 2002-10-27 1:00 EST and you get 2002-10-27 0:59 EST instead of the correct 2002-10-27 1:59 EDT). A ``normalize()`` method is provided to correct this. Unfortunatly these issues cannot be resolved without modifying the Python datetime implementation. Installation ~~~~~~~~~~~~ This package can either be installed from a .egg file using setuptools, or from the tarball using the standard Python distutils. If you are installing from a tarball, run the following command as an administrative user:: python setup.py install If you are installing using setuptools, you don't even need to download anything as the latest version will be downloaded for you from the Python package index:: easy_install --upgrade pytz If you already have the .egg file, you can use that too:: easy_install pytz-2008g-py2.6.egg Example & Usage ~~~~~~~~~~~~~~~ Localized times and date arithmetic ----------------------------------- >>> from datetime import datetime, timedelta >>> from pytz import timezone >>> import pytz >>> utc = pytz.utc >>> utc.zone 'UTC' >>> eastern = timezone('US/Eastern') >>> eastern.zone 'US/Eastern' >>> amsterdam = timezone('Europe/Amsterdam') >>> fmt = '%Y-%m-%d %H:%M:%S %Z%z' This library only supports two ways of building a localized time. The first is to use the ``localize()`` method provided by the pytz library. This is used to localize a naive datetime (datetime with no timezone information): >>> loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0)) >>> print loc_dt.strftime(fmt) 2002-10-27 06:00:00 EST-0500 The second way of building a localized time is by converting an existing localized time using the standard ``astimezone()`` method: >>> ams_dt = loc_dt.astimezone(amsterdam) >>> ams_dt.strftime(fmt) '2002-10-27 12:00:00 CET+0100' Unfortunately using the tzinfo argument of the standard datetime constructors ''does not work'' with pytz for many timezones. >>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=amsterdam).strftime(fmt) '2002-10-27 12:00:00 AMT+0020' It is safe for timezones without daylight savings trasitions though, such as UTC: >>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=pytz.utc).strftime(fmt) '2002-10-27 12:00:00 UTC+0000' The preferred way of dealing with times is to always work in UTC, converting to localtime only when generating output to be read by humans. >>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc) >>> loc_dt = utc_dt.astimezone(eastern) >>> loc_dt.strftime(fmt) '2002-10-27 01:00:00 EST-0500' This library also allows you to do date arithmetic using local times, although it is more complicated than working in UTC as you need to use the ``normalize()`` method to handle daylight savings time and other timezone transitions. In this example, ``loc_dt`` is set to the instant when daylight savings time ends in the US/Eastern timezone. >>> before = loc_dt - timedelta(minutes=10) >>> before.strftime(fmt) '2002-10-27 00:50:00 EST-0500' >>> eastern.normalize(before).strftime(fmt) '2002-10-27 01:50:00 EDT-0400' >>> after = eastern.normalize(before + timedelta(minutes=20)) >>> after.strftime(fmt) '2002-10-27 01:10:00 EST-0500' Creating localtimes is also tricky, and the reason why working with local times is not recommended. Unfortunately, you cannot just pass a ``tzinfo`` argument when constructing a datetime (see the next section for more details) >>> dt = datetime(2002, 10, 27, 1, 30, 0) >>> dt1 = eastern.localize(dt, is_dst=True) >>> dt1.strftime(fmt) '2002-10-27 01:30:00 EDT-0400' >>> dt2 = eastern.localize(dt, is_dst=False) >>> dt2.strftime(fmt) '2002-10-27 01:30:00 EST-0500' Converting between timezones also needs special attention. This also needs to use the ``normalize()`` method to ensure the conversion is correct. >>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899)) >>> utc_dt.strftime(fmt) '2006-03-26 21:34:59 UTC+0000' >>> au_tz = timezone('Australia/Sydney') >>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz)) >>> au_dt.strftime(fmt) '2006-03-27 08:34:59 EST+1100' >>> utc_dt2 = utc.normalize(au_dt.astimezone(utc)) >>> utc_dt2.strftime(fmt) '2006-03-26 21:34:59 UTC+0000' You can take shortcuts when dealing with the UTC side of timezone conversions. ``normalize()`` and ``localize()`` are not really necessary when there are no daylight savings time transitions to deal with. >>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc) >>> utc_dt.strftime(fmt) '2006-03-26 21:34:59 UTC+0000' >>> au_tz = timezone('Australia/Sydney') >>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz)) >>> au_dt.strftime(fmt) '2006-03-27 08:34:59 EST+1100' >>> utc_dt2 = au_dt.astimezone(utc) >>> utc_dt2.strftime(fmt) '2006-03-26 21:34:59 UTC+0000' ``tzinfo`` API -------------- The ``tzinfo`` instances returned by the ``timezone()`` function have been extended to cope with ambiguous times by adding an ``is_dst`` parameter to the ``utcoffset()``, ``dst()`` && ``tzname()`` methods. >>> tz = timezone('America/St_Johns') >>> normal = datetime(2009, 9, 1) >>> ambiguous = datetime(2009, 10, 31, 23, 30) the ``is_dst`` parameter is ignormed for most timestamps, but is used to resolve the ambiguity during ambiguous periods caused to DST transitions. >>> tz.utcoffset(normal, is_dst=True) datetime.timedelta(-1, 77400) >>> tz.dst(normal, is_dst=True) datetime.timedelta(0, 3600) >>> tz.tzname(normal, is_dst=True) 'NDT' >>> tz.utcoffset(ambiguous, is_dst=True) datetime.timedelta(-1, 77400) >>> tz.dst(ambiguous, is_dst=True) datetime.timedelta(0, 3600) >>> tz.tzname(ambiguous, is_dst=True) 'NDT' >>> tz.utcoffset(normal, is_dst=False) datetime.timedelta(-1, 77400) >>> tz.dst(normal, is_dst=False) datetime.timedelta(0, 3600) >>> tz.tzname(normal, is_dst=False) 'NDT' >>> tz.utcoffset(ambiguous, is_dst=False) datetime.timedelta(-1, 73800) >>> tz.dst(ambiguous, is_dst=False) datetime.timedelta(0) >>> tz.tzname(ambiguous, is_dst=False) 'NST' If ``is_dst`` is not specified, ambiguous timestamps will raise an ``AmbiguousTimeError`` exception. >>> tz.utcoffset(normal) datetime.timedelta(-1, 77400) >>> tz.dst(normal) datetime.timedelta(0, 3600) >>> tz.tzname(normal) 'NDT' >>> tz.utcoffset(ambiguous) Traceback (most recent call last): [...] AmbiguousTimeError: 2009-10-31 23:30:00 >>> tz.dst(ambiguous) Traceback (most recent call last): [...] AmbiguousTimeError: 2009-10-31 23:30:00 >>> tz.tzname(ambiguous) Traceback (most recent call last): [...] AmbiguousTimeError: 2009-10-31 23:30:00 Problems with Localtime ~~~~~~~~~~~~~~~~~~~~~~~ The major problem we have to deal with is that certain datetimes may occur twice in a year. For example, in the US/Eastern timezone on the last Sunday morning in October, the following sequence happens: - 01:00 EDT occurs - 1 hour later, instead of 2:00am the clock is turned back 1 hour and 01:00 happens again (this time 01:00 EST) In fact, every instant between 01:00 and 02:00 occurs twice. This means that if you try and create a time in the 'US/Eastern' timezone using the standard datetime syntax, there is no way to specify if you meant before of after the end-of-daylight-savings-time transition. >>> loc_dt = datetime(2002, 10, 27, 1, 30, 00, tzinfo=eastern) >>> loc_dt.strftime(fmt) '2002-10-27 01:30:00 EST-0500' As you can see, the system has chosen one for you and there is a 50% chance of it being out by one hour. For some applications, this does not matter. However, if you are trying to schedule meetings with people in different timezones or analyze log files it is not acceptable. The best and simplest solution is to stick with using UTC. The pytz package encourages using UTC for internal timezone representation by including a special UTC implementation based on the standard Python reference implementation in the Python documentation. This timezone unpickles to be the same instance, and pickles to a relatively small size. The UTC implementation can be obtained as pytz.utc, pytz.UTC, or pytz.timezone('UTC'). >>> import pickle, pytz >>> dt = datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc) >>> naive = dt.replace(tzinfo=None) >>> p = pickle.dumps(dt, 1) >>> naive_p = pickle.dumps(naive, 1) >>> len(p), len(naive_p), len(p) - len(naive_p) (60, 43, 17) >>> new = pickle.loads(p) >>> new == dt True >>> new is dt False >>> new.tzinfo is dt.tzinfo True >>> pytz.utc is pytz.UTC is pytz.timezone('UTC') True Note that this instance is not the same instance (or implementation) as other timezones with the same meaning (GMT, Greenwich, Universal, etc.). >>> utc is pytz.timezone('GMT') False If you insist on working with local times, this library provides a facility for constructing them unambiguously: >>> loc_dt = datetime(2002, 10, 27, 1, 30, 00) >>> est_dt = eastern.localize(loc_dt, is_dst=True) >>> edt_dt = eastern.localize(loc_dt, is_dst=False) >>> print est_dt.strftime(fmt), '/', edt_dt.strftime(fmt) 2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500 If you pass None as the is_dst flag to localize(), pytz will refuse to guess and raise exceptions if you try to build ambiguous or non-existent times. For example, 1:30am on 27th Oct 2002 happened twice in the US/Eastern timezone when the clocks where put back at the end of Daylight Savings Time: >>> eastern.localize(datetime(2002, 10, 27, 1, 30, 00), is_dst=None) Traceback (most recent call last): ... AmbiguousTimeError: 2002-10-27 01:30:00 Similarly, 2:30am on 7th April 2002 never happened at all in the US/Eastern timezone, as the clocks where put forward at 2:00am skipping the entire hour: >>> eastern.localize(datetime(2002, 4, 7, 2, 30, 00), is_dst=None) Traceback (most recent call last): ... NonExistentTimeError: 2002-04-07 02:30:00 Both of these exceptions share a common base class to make error handling easier: >>> isinstance(pytz.AmbiguousTimeError(), pytz.InvalidTimeError) True >>> isinstance(pytz.NonExistentTimeError(), pytz.InvalidTimeError) True Although ``localize()`` handles many cases, it is still not possible to handle all. In cases where countries change their timezone definitions, cases like the end-of-daylight-savings-time occur with no way of resolving the ambiguity. For example, in 1915 Warsaw switched from Warsaw time to Central European time. So at the stroke of midnight on August 5th 1915 the clocks were wound back 24 minutes creating an ambiguous time period that cannot be specified without referring to the timezone abbreviation or the actual UTC offset. In this case midnight happened twice, neither time during a daylight savings time period: >>> warsaw = pytz.timezone('Europe/Warsaw') >>> loc_dt1 = warsaw.localize(datetime(1915, 8, 4, 23, 59, 59), is_dst=False) >>> loc_dt1.strftime(fmt) '1915-08-04 23:59:59 WMT+0124' >>> loc_dt2 = warsaw.localize(datetime(1915, 8, 5, 00, 00, 00), is_dst=False) >>> loc_dt2.strftime(fmt) '1915-08-05 00:00:00 CET+0100' >>> str(loc_dt2 - loc_dt1) '0:24:01' The only way of creating a time during the missing 24 minutes is converting from another timezone - because neither of the timezones involved where in daylight savings mode the API simply provides no way to express it: >>> utc_dt = datetime(1915, 8, 4, 22, 36, tzinfo=pytz.utc) >>> utc_dt.astimezone(warsaw).strftime(fmt) '1915-08-04 23:36:00 CET+0100' The standard Python way of handling all these ambiguities is not to handle them, such as demonstrated in this example using the US/Eastern timezone definition from the Python documentation (Note that this implementation only works for dates between 1987 and 2006 - it is included for tests only!): >>> from pytz.reference import Eastern # pytz.reference only for tests >>> dt = datetime(2002, 10, 27, 0, 30, tzinfo=Eastern) >>> str(dt) '2002-10-27 00:30:00-04:00' >>> str(dt + timedelta(hours=1)) '2002-10-27 01:30:00-05:00' >>> str(dt + timedelta(hours=2)) '2002-10-27 02:30:00-05:00' >>> str(dt + timedelta(hours=3)) '2002-10-27 03:30:00-05:00' Notice the first two results? At first glance you might think they are correct, but taking the UTC offset into account you find that they are actually two hours appart instead of the 1 hour we asked for. >>> from pytz.reference import UTC # pytz.reference only for tests >>> str(dt.astimezone(UTC)) '2002-10-27 04:30:00+00:00' >>> str((dt + timedelta(hours=1)).astimezone(UTC)) '2002-10-27 06:30:00+00:00' Country Information ~~~~~~~~~~~~~~~~~~~ A mechanism is provided to access the timezones commonly in use for a particular country, looked up using the ISO 3166 country code. It returns a list of strings that can be used to retrieve the relevant tzinfo instance using ``pytz.timezone()``: >>> pytz.country_timezones['nz'] ['Pacific/Auckland', 'Pacific/Chatham'] The Olson database comes with a ISO 3166 country code to English country name mapping that pytz exposes as a dictionary: >>> pytz.country_names['nz'] 'New Zealand' What is UTC ~~~~~~~~~~~ 'UTC' is Universal Time, also known as Greenwich Mean Time or GMT in the United Kingdom. All other timezones are given as offsets from UTC. No daylight savings time occurs in UTC, making it a useful timezone to perform date arithmetic without worrying about the confusion and ambiguities caused by daylight savings time transitions, your country changing its timezone, or mobile computers that move roam through multiple timezones. Helpers ~~~~~~~ There are two lists of timezones provided. ``all_timezones`` is the exhaustive list of the timezone names that can be used. >>> from pytz import all_timezones >>> len(all_timezones) >= 500 True >>> 'Etc/Greenwich' in all_timezones True ``common_timezones`` is a list of useful, current timezones. It doesn't contain deprecated zones or historical zones, except for a few I've deemed in common usage, such as US/Eastern (open a bug report if you think other timezones are deserving of being included here). It is also a sequence of strings. >>> from pytz import common_timezones >>> len(common_timezones) < len(all_timezones) True >>> 'Etc/Greenwich' in common_timezones False >>> 'Australia/Melbourne' in common_timezones True >>> 'US/Eastern' in common_timezones True >>> 'Canada/Eastern' in common_timezones True >>> 'US/Pacific-New' in all_timezones True >>> 'US/Pacific-New' in common_timezones False Both ``common_timezones`` and ``all_timezones`` are alphabetically sorted: >>> common_timezones_dupe = common_timezones[:] >>> common_timezones_dupe.sort() >>> common_timezones == common_timezones_dupe True >>> all_timezones_dupe = all_timezones[:] >>> all_timezones_dupe.sort() >>> all_timezones == all_timezones_dupe True ``all_timezones`` and ``common_timezones`` are also available as sets. >>> from pytz import all_timezones_set, common_timezones_set >>> 'US/Eastern' in all_timezones_set True >>> 'US/Eastern' in common_timezones_set True >>> 'Australia/Victoria' in common_timezones_set False You can also retrieve lists of timezones used by particular countries using the ``country_timezones()`` function. It requires an ISO-3166 two letter country code. >>> from pytz import country_timezones >>> country_timezones('ch') ['Europe/Zurich'] >>> country_timezones('CH') ['Europe/Zurich'] License ~~~~~~~ MIT license. This code is also available as part of Zope 3 under the Zope Public License, Version 2.1 (ZPL). I'm happy to relicense this code if necessary for inclusion in other open source projects. Latest Versions ~~~~~~~~~~~~~~~ This package will be updated after releases of the Olson timezone database. The latest version can be downloaded from the `Python Package Index `_. The code that is used to generate this distribution is hosted on launchpad.net and available using the `Bazaar version control system `_ using:: bzr branch lp:pytz Bugs, Feature Requests & Patches ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bugs can be reported using `Launchpad `_. Issues & Limitations ~~~~~~~~~~~~~~~~~~~~ - Offsets from UTC are rounded to the nearest whole minute, so timezones such as Europe/Amsterdam pre 1937 will be up to 30 seconds out. This is a limitation of the Python datetime library. - If you think a timezone definition is incorrect, I probably can't fix it. pytz is a direct translation of the Olson timezone database, and changes to the timezone definitions need to be made to this source. If you find errors they should be reported to the time zone mailing list, linked from http://www.twinsun.com/tz/tz-link.htm Further Reading ~~~~~~~~~~~~~~~ More info than you want to know about timezones: http://www.twinsun.com/tz/tz-link.htm Contact ~~~~~~~ Stuart Bishop Keywords: timezone,tzinfo,datetime,olson,time Platform: Independant Classifier: Development Status :: 6 - Mature Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Software Development :: Libraries :: Python Modules