Skip to content

Default to using system zoneinfo if available #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pydantic_extra_types/timezone_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ def _warn_about_pytz_usage() -> None:

def get_timezones() -> set[str]:
"""Determine the timezone provider and return available timezones."""
if _is_available('zoneinfo') and _is_available('tzdata'): # pragma: no cover
return _tz_provider_from_zone_info()
if _is_available('zoneinfo'): # pragma: no cover
timezones = _tz_provider_from_zone_info()
if len(timezones) == 0: # pragma: no cover
raise ImportError('No timezone provider found. Please install tzdata with "pip install tzdata"')
return timezones
elif _is_available('pytz'): # pragma: no cover
return _tz_provider_from_pytz()
else: # pragma: no cover
Expand Down