ziptz
US ZIP code to IANA time zone, from about 1.3 KB of tables. No dependencies, no data files, no network: the tables are string constants in the source, and the first lookup unpacks them into a dict, so a lookup is a hash.
pip install ziptz-us # the module is ziptz
>>> import ziptz
>>> ziptz.zone("94110")
'America/Los_Angeles'
>>> ziptz.location("10001")
zoneinfo.ZoneInfo(key='America/New_York')
>>> ziptz.abbrev("94110") # at an instant you pass, or now
'PDT'
>>> ziptz.generic("94110") # the same zone, daylight saving left out
'PT'
The distribution is ziptz-us and the module is ziptz, the same split as
python-dateutil and dateutil: the bare name on PyPI is a 2013 registration
with no files attached, and -us is in any case accurate for something that
resolves US ZIP codes and nothing else.
Accuracy
Five digits are exact. Three — the prefix alone — give the majority zone for that prefix, right for 33,558 of the 33,791 ZIP codes and wrong for the 233 that sit on the losing side of a boundary their prefix has to round across.
ziptz.zone("79835") # America/Denver — Canutillo, TX; five digits are exact
ziptz.zone("798") # America/Chicago — the prefix rounds to the majority
It covers the places a US-only table usually forgets — Puerto Rico, the Virgin Islands, Guam, the Northern Marianas, American Samoa — and it answers a 3-digit prefix on its own, which is what you have when an address is half filled in.
Three things to know before depending on it:
- It is not a ZIP validator. A five-digit code with an assigned prefix always gets an answer, whether or not the Postal Service ever issued it. An error means "no such prefix", never "no such ZIP".
- Zone names are coarser than the tz database's. About 34 IANA zones fold
onto the 11 that agree with them today, so a ZIP in Knox County, Indiana
answers
America/New_Yorkrather thanAmerica/Indiana/Knox. The clock is right; the name is less specific. - PO-box and single-building ZIPs have no delivery area in the source data
and fall back to their prefix. Where a whole prefix is nothing but those,
there is nothing to fall back to and the lookup is an error —
00501(Holtsville, NY) is the named case.
The tables carry today's zone names, not today's offsets. Daylight saving comes from whatever tzdata the machine has, so a rule change needs no release here — and the tables are wrong for historical dates, since several places have changed zone and these record only where each ZIP is now.
Typed, ships py.typed, and supports Python 3.9 and up. Every answer is
checked against a second independent implementation of the same tables — all
101,000 tokens, on every build — so "the two agree" is a build step rather than
a claim.
MIT licensed. The tables derive from US Census ZCTA centroids (public domain)
resolved through timezone-boundary-builder (ODbL); the NOTICE
file shipped in this distribution carries that attribution and should travel
with any copy.
Full documentation, the accuracy notes in depth, and the source: https://github.com/choey/ziptz
Metadata
Release files for ziptz-us 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ziptz_us-0.1.2.tar.gz | 44.8 kB | Without provenance | Details for ziptz_us-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ziptz_us-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for ziptz_us-0.1.2-py3-none-any.whl |
Total release size: 66.4 kB
Release files / ziptz_us-0.1.2.tar.gz
| Download URL | ziptz_us-0.1.2.tar.gz |
|---|---|
| Size | 44.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfeee63911e601c72ac97a55973b9f0fd538bf4dc4c0207bab2be3901f61665a
|
|
BLAKE2b-256 checksum How to use checksums |
09506020a2b8268db4d522d6cfea49d1057d537233f3ff5808a9ab554c103a40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / ziptz_us-0.1.2-py3-none-any.whl
| Download URL | ziptz_us-0.1.2-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f4c012acc6f089b174e7d2f03f2921c13354f15e161501a5cb61c82e90f78be
|
|
BLAKE2b-256 checksum How to use checksums |
c1ab66ac2038482c50b87ef14fcaa0b1a19fb09f7b1cc270bf0b2bd95c4f27eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for ziptz-us 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.