Mercurial > personal > weather-server
comparison 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 |
comparison
equal
deleted
inserted
replaced
38:d5a18ecebf47 | 39:b77c8e7d2742 |
---|---|
2 | 2 |
3 import configparser | 3 import configparser |
4 import datetime | 4 import datetime |
5 import pathlib | 5 import pathlib |
6 import typing as t | 6 import typing as t |
7 | 7 import zoneinfo |
8 import pytz | |
9 | 8 |
10 from . import logfile | 9 from . import logfile |
11 from . import types | 10 from . import types |
12 | 11 |
13 CONFIG_FILE = 'config.ini' | 12 CONFIG_FILE = 'config.ini' |
59 pass # go to the older one. | 58 pass # go to the older one. |
60 return None | 59 return None |
61 | 60 |
62 def timezone(self) -> datetime.tzinfo: | 61 def timezone(self) -> datetime.tzinfo: |
63 try: | 62 try: |
64 return pytz.timezone(self.tz_name) | 63 return zoneinfo.ZoneInfo(self.tz_name) |
65 except pytz.UnknownTimeZoneError: | 64 except zoneinfo.ZoneInfoNotFoundError: |
66 return pytz.UTC | 65 return datetime.UTC |
67 | 66 |
68 def __repr__(self) -> str: | 67 def __repr__(self) -> str: |
69 return f'<Location in {self.root!r}>' | 68 return f'<Location in {self.root!r}>' |
70 | 69 |
71 | 70 |