Mercurial > personal > weather-server
diff weather_server/locations.py @ 39:b77c8e7d2742
Use zoneinfo rather than pytz.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Tue, 01 Apr 2025 15:54:21 -0400 |
parents | 2f3473416c11 |
children |
line wrap: on
line diff
--- a/weather_server/locations.py Tue Apr 01 15:46:16 2025 -0400 +++ b/weather_server/locations.py Tue Apr 01 15:54:21 2025 -0400 @@ -4,8 +4,7 @@ import datetime import pathlib import typing as t - -import pytz +import zoneinfo from . import logfile from . import types @@ -61,9 +60,9 @@ def timezone(self) -> datetime.tzinfo: try: - return pytz.timezone(self.tz_name) - except pytz.UnknownTimeZoneError: - return pytz.UTC + return zoneinfo.ZoneInfo(self.tz_name) + except zoneinfo.ZoneInfoNotFoundError: + return datetime.UTC def __repr__(self) -> str: return f'<Location in {self.root!r}>'