diff --git a/django/utils/timezone.py b/django/utils/timezone.py index a56ff0b6ab..3493e056fb 100644 --- a/django/utils/timezone.py +++ b/django/utils/timezone.py @@ -80,7 +80,8 @@ class LocalTimezone(tzinfo): return ZERO def tzname(self, dt): - return _time.tzname[self._isdst(dt)] + is_dst = False if dt is None else self._isdst(dt) + return _time.tzname[is_dst] def _isdst(self, dt): tt = (dt.year, dt.month, dt.day, @@ -145,8 +146,7 @@ def _get_timezone_name(timezone): return timezone.zone except AttributeError: # for regular tzinfo objects - local_now = datetime.now(timezone) - return timezone.tzname(local_now) + return timezone.tzname(None) # Timezone selection functions. diff --git a/django/utils/tzinfo.py b/django/utils/tzinfo.py index 654c99778e..fd221ea48b 100644 --- a/django/utils/tzinfo.py +++ b/django/utils/tzinfo.py @@ -71,9 +71,9 @@ class LocalTimezone(tzinfo): return timedelta(0) def tzname(self, dt): + is_dst = False if dt is None else self._isdst(dt) try: - return force_text(time.tzname[self._isdst(dt)], - DEFAULT_LOCALE_ENCODING) + return force_text(time.tzname[is_dst], DEFAULT_LOCALE_ENCODING) except UnicodeDecodeError: return None