Port variant py38
Summary World timezone definitions (PY38)
Package version 2021.3
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants py39
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 01 OCT 2021, 04:31:47 UTC
Port created 20 APR 2017, 05:12:41 UTC
Subpackage Descriptions
single 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.4 or higher. It also solves the issue of ambiguous times at the end of daylight saving time, which you can read more about in the Python Library Reference (``datetime.tzinfo``). Almost all of the Olson timezones are supported. .. note:: 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 result 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. Unfortunately these issues cannot be resolved without modifying the Python datetime implementation (see PEP-431). Installation ~~~~~~~~~~~~ This package can either be installed using pip or from a tarball using the standard Python distutils. If you are installing using pip, you don't need to download anything as the latest version will be downloaded for you from PyPI:: pip install pytz If you are installing from a tarball, run the following command as an administrative user:: python install pytz for Enterprise ~~~~~~~~~~~~~~~~~~~ Available as part of the Tidelift Subscription. The maintainers of pytz and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. `Learn more. `_. Example & Usage ~~~~~~~~~~~~~~~ Localized times and date arithmetic ----------------------------------- >>> from datetime import datetime, timedelta >>> from pytz import timezone >>> import pytz >>> utc = pytz.utc >>> 'UTC' >>> eastern = timezone('US/Eastern') >>> '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) # /!\ Does not work this way! '2002-10-27 12:00:00 LMT+0020' It is safe for timezones without daylight saving transitions though, such as UTC:
Configuration Switches (platform-specific settings discarded)
PY38 ON Build using Python 3.8 PY39 OFF Build using Python 3.9
Package Dependencies by Type
Build (only) python-pip:single:py38
Build and Runtime python38:single:standard
Download groups
main mirror://PYPIWHL/d3/e3/d9f046b5d1c94a3aeab15f1f867aa414f8ee9d196fae6865f1d6a0ee1a0b
Distribution File Information
3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c 503471 pytz-2021.3-py2.py3-none-any.whl
Ports that require python-pytz:py38
python-Babel:py38 Internationalization utilities (PY38)
python-Django:py38 High-level Python Web framework (PY38)
python-Flask-RESTful:py38 Simple framework for creating REST APIs (PY38)
python-celery:py38 Distributed Task Queue (PY38)
python-fs:py38 Python's filesystem abstraction layer (PY38)
python-pandas:py38 Data structures for time series, statistics (PY38)