summaryrefslogtreecommitdiff
path: root/django/utils/http.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/utils/http.py')
-rw-r--r--django/utils/http.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/django/utils/http.py b/django/utils/http.py
index cfd982fc01..78dfee7fee 100644
--- a/django/utils/http.py
+++ b/django/utils/http.py
@@ -1,8 +1,8 @@
import base64
-import datetime
import re
import unicodedata
from binascii import Error as BinasciiError
+from datetime import datetime, timezone
from email.utils import formatdate
from urllib.parse import quote, unquote
from urllib.parse import urlencode as original_urlencode
@@ -113,10 +113,9 @@ def parse_http_date(date):
else:
raise ValueError("%r is not in a valid HTTP date format" % date)
try:
- tz = datetime.timezone.utc
year = int(m["year"])
if year < 100:
- current_year = datetime.datetime.now(tz=tz).year
+ current_year = datetime.now(tz=timezone.utc).year
current_century = current_year - (current_year % 100)
if year - (current_year % 100) > 50:
# year that appears to be more than 50 years in the future are
@@ -129,7 +128,7 @@ def parse_http_date(date):
hour = int(m["hour"])
min = int(m["min"])
sec = int(m["sec"])
- result = datetime.datetime(year, month, day, hour, min, sec, tzinfo=tz)
+ result = datetime(year, month, day, hour, min, sec, tzinfo=timezone.utc)
return int(result.timestamp())
except Exception as exc:
raise ValueError("%r is not a valid date" % date) from exc