Registry / http-networking / aiozoneinfo

aiozoneinfo

JSON →
library0.2.3pypypi✓ verified 83d ago

aiozoneinfo is an asyncio-compatible Python library that provides tools to asynchronously fetch and access zoneinfo timezone data. It integrates seamlessly with asynchronous applications requiring up-to-date timezone information. The current version is 0.2.3, with a release cadence focused on minor fixes and improvements.

pip install aiozoneinfo
INSTALL
IMPORT
SIG · AIOZONEINFO
A
aiozoneinfo
http-networkingpythonv0.2.3
Install
1.7s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.7s · import 0.000s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

async_get_time_zone
from aiozoneinfo import async_get_time_zone
from aiozoneinfo import ZoneInfo
get_time_zone
from aiozoneinfo import get_time_zone
CachedZoneInfo
from aiozoneinfo import CachedZoneInfo

This quickstart demonstrates how to initialize the `ZoneInfo` client and asynchronously fetch timezone data using `async_get_timezone`. It also includes basic error handling for invalid timezone names.

import asyncio from aiozoneinfo import ZoneInfo async def get_timezone_data(timezone_name: str): """Fetches timezone data asynchronously.""" zoneinfo_fetcher = ZoneInfo() try: tz = await zoneinfo_fetcher.async_get_timezone(timezone_name) print(f"Fetched timezone for {timezone_name}: {tz}") # You can now use 'tz' with datetime objects: # import datetime # dt_utc = datetime.datetime.now(datetime.timezone.utc) # dt_local = dt_utc.astimezone(tz) # print(f"Current time in {timezone_name}: {dt_local}") except Exception as e: print(f"Error fetching timezone {timezone_name}: {e}") async def main(): await get_timezone_data("America/New_York") await get_timezone_data("Europe/London") await get_timezone_data("Invalid/Timezone") if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
gotchaaiozoneinfo relies on an active internet connection to fetch timezone data. Operations will fail if there is no network connectivity or if the remote server is unreachable.
fix
Ensure stable network connectivity. Implement retry mechanisms or local caching for resilience in production environments.
affects: All
gotchaIncorrect or misspelled timezone names passed to `async_get_timezone` will result in an `aiozoneinfo.exceptions.ZoneInfoNotFound` exception.
fix
Always use valid IANA Time Zone Database names (e.g., 'America/New_York', 'Europe/London'). Consider validating user input against a known list of timezones.
affects: All
gotchaAs an asyncio library, ensure all calls to `aiozoneinfo` methods are `await`ed within an `async` function and executed within an asyncio event loop (e.g., via `asyncio.run()`).
fix
Prefix all `aiozoneinfo` method calls with `await`. Wrap your top-level async function with `asyncio.run()` when running from a synchronous context.
affects: All
Upgrade
Version history
0.2.3latest on PyPI · released Feb 4, 2025
Audit
Dependencies
httpxrequiredUsed for making asynchronous HTTP requests to fetch zoneinfo data.
Agent activity
57 hits · last 30 days
node
48
OpenAI (training)
2
Resources
aiozoneinfo — pip install aiozoneinfo · libregistry