Fix _UtcCompat: add missing normalize() method

- ldapdb calls timezone.utc.normalize() for datetime field conversion
- Added normalize() method that works the same as localize() for UTC
- Fixes AttributeError: '_UtcCompat' object has no attribute 'normalize'
This commit is contained in:
lizerk 2026-03-20 00:21:04 +03:00
parent ca1deac82b
commit 4cf989e5b5

View File

@ -109,13 +109,17 @@ if not hasattr(_dj_tz, 'utc'):
"""pytz-compatible UTC wrapper for django-ldapdb.
Acts as a tzinfo subclass but delegates to datetime.timezone.utc
and provides the localize() method for pytz compatibility.
and provides pytz-compatible methods: localize() and normalize().
"""
def localize(self, dt):
"""pytz-style localize method."""
return dt.replace(tzinfo=_dt.timezone.utc)
def normalize(self, dt):
"""pytz-style normalize method - same as localize for UTC."""
return dt.replace(tzinfo=_dt.timezone.utc)
def utcoffset(self, dt):
return _dt.timedelta(0)