Ticket #37110: zoneinfo-patch.diff

File zoneinfo-patch.diff, 1.2 KB (added by jodizzle, 2 hours ago)
  • django/conf/__init__.py

    diff --git a/django/conf/__init__.py b/django/conf/__init__.py
    index 5bf4cf13ae..39a389ae63 100644
    a b import importlib  
    1010import os
    1111import time
    1212import warnings
    13 from pathlib import Path
     13import zoneinfo
    1414
    1515from django.conf import global_settings
    1616from django.core.exceptions import ImproperlyConfigured
    class Settings:  
    276276            )
    277277
    278278        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:
    284282                raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
    285283            # Move the time zone info into os.environ. See ticket #2315 for why
    286284            # we don't do this unconditionally (breaks Windows).
Back to Top