Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Accepted None in tzname().

This is required by the tzinfo API, see Python's docs.

Also made _get_timezone_name deterministic.
  • Loading branch information...
commit 5a3d9490f14263cc4ed78b6adcb764936b07b4ae 1 parent 7db770b
@aaugustin aaugustin authored
Showing with 5 additions and 5 deletions.
  1. +3 −3 django/utils/timezone.py
  2. +2 −2 django/utils/tzinfo.py
View
6 django/utils/timezone.py
@@ -80,7 +80,8 @@ def dst(self, dt):
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.
View
4 django/utils/tzinfo.py
@@ -71,9 +71,9 @@ def dst(self, dt):
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
Please sign in to comment.
Something went wrong with that request. Please try again.