{"id":6972,"library":"aiozoneinfo","title":"aiozoneinfo","description":"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.","status":"active","version":"0.2.3","language":"en","source_language":"en","source_url":"https://github.com/bluetooth-devices/aiozoneinfo","tags":["asyncio","timezone","zoneinfo","datetime"],"install":[{"cmd":"pip install aiozoneinfo","lang":"bash","label":"Install aiozoneinfo"}],"dependencies":[{"reason":"Used for making asynchronous HTTP requests to fetch zoneinfo data.","package":"httpx","optional":false}],"imports":[{"symbol":"ZoneInfo","correct":"from aiozoneinfo import ZoneInfo"}],"quickstart":{"code":"import asyncio\nfrom aiozoneinfo import ZoneInfo\n\nasync def get_timezone_data(timezone_name: str):\n    \"\"\"Fetches timezone data asynchronously.\"\"\"\n    zoneinfo_fetcher = ZoneInfo()\n    try:\n        tz = await zoneinfo_fetcher.async_get_timezone(timezone_name)\n        print(f\"Fetched timezone for {timezone_name}: {tz}\")\n        # You can now use 'tz' with datetime objects:\n        # import datetime\n        # dt_utc = datetime.datetime.now(datetime.timezone.utc)\n        # dt_local = dt_utc.astimezone(tz)\n        # print(f\"Current time in {timezone_name}: {dt_local}\")\n    except Exception as e:\n        print(f\"Error fetching timezone {timezone_name}: {e}\")\n\nasync def main():\n    await get_timezone_data(\"America/New_York\")\n    await get_timezone_data(\"Europe/London\")\n    await get_timezone_data(\"Invalid/Timezone\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"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."},"warnings":[{"fix":"Ensure stable network connectivity. Implement retry mechanisms or local caching for resilience in production environments.","message":"aiozoneinfo 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Incorrect or misspelled timezone names passed to `async_get_timezone` will result in an `aiozoneinfo.exceptions.ZoneInfoNotFound` exception.","severity":"gotcha","affected_versions":"All"},{"fix":"Prefix all `aiozoneinfo` method calls with `await`. Wrap your top-level async function with `asyncio.run()` when running from a synchronous context.","message":"As 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()`).","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the library using pip: `pip install aiozoneinfo`","cause":"The aiozoneinfo library has not been installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'aiozoneinfo'"},{"fix":"Verify the timezone string is correct (e.g., 'America/New_York', 'Europe/Paris'). Check the IANA Time Zone Database for valid names.","cause":"The specified timezone identifier is not a valid IANA Time Zone Database name or could not be found by the service.","error":"aiozoneinfo.exceptions.ZoneInfoNotFound: Timezone 'Some/Invalid_Zone' not found"},{"fix":"Ensure all calls to `aiozoneinfo` methods (like `async_get_timezone`) are prefixed with `await`.","cause":"You likely forgot to `await` a call to an aiozoneinfo async method, leading to a coroutine object being passed where an awaited result was expected.","error":"RuntimeError: An asyncio.Future, a coroutine or an awaitable is required instead of None"}]}