diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index 5bf4cf13ae..39a389ae63 100644
|
a
|
b
|
import importlib
|
| 10 | 10 | import os |
| 11 | 11 | import time |
| 12 | 12 | import warnings |
| 13 | | from pathlib import Path |
| | 13 | import zoneinfo |
| 14 | 14 | |
| 15 | 15 | from django.conf import global_settings |
| 16 | 16 | from django.core.exceptions import ImproperlyConfigured |
| … |
… |
class Settings:
|
| 276 | 276 | ) |
| 277 | 277 | |
| 278 | 278 | if hasattr(time, "tzset") and self.TIME_ZONE: |
| 279 | | # When we can, attempt to validate the timezone. If we can't find |
| 280 | | # this file, no check happens and it's harmless. |
| 281 | | zoneinfo_root = Path("/usr/share/zoneinfo") |
| 282 | | zone_info_file = zoneinfo_root.joinpath(*self.TIME_ZONE.split("/")) |
| 283 | | if zoneinfo_root.exists() and not zone_info_file.exists(): |
| | 279 | try: |
| | 280 | zoneinfo.ZoneInfo(self.TIME_ZONE) |
| | 281 | except zoneinfo.ZoneInfoNotFoundError: |
| 284 | 282 | raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE) |
| 285 | 283 | # Move the time zone info into os.environ. See ticket #2315 for why |
| 286 | 284 | # we don't do this unconditionally (breaks Windows). |