diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-02-18 08:35:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-18 08:35:36 +0100 |
| commit | efb7f9ced2dcf71294353596a265e3fd67faffeb (patch) | |
| tree | b24b6127022fbe48c517d1acbe9e3c0c502391d9 /django/utils/http.py | |
| parent | 0d1dd6bba0c18b7feb6caa5cbd8df80fbac54afd (diff) | |
Refs #36005 -- Used datetime.UTC alias instead of datetime.timezone.utc.
datetime.UTC was added in Python 3.11.
Diffstat (limited to 'django/utils/http.py')
| -rw-r--r-- | django/utils/http.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/utils/http.py b/django/utils/http.py index 2098cbc36d..9ca32eab08 100644 --- a/django/utils/http.py +++ b/django/utils/http.py @@ -2,7 +2,7 @@ import base64 import re import unicodedata from binascii import Error as BinasciiError -from datetime import datetime, timezone +from datetime import UTC, datetime from email.utils import formatdate from urllib.parse import quote, unquote from urllib.parse import urlencode as original_urlencode @@ -115,7 +115,7 @@ def parse_http_date(date): try: year = int(m["year"]) if year < 100: - current_year = datetime.now(tz=timezone.utc).year + current_year = datetime.now(tz=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 @@ -128,7 +128,7 @@ def parse_http_date(date): hour = int(m["hour"]) min = int(m["min"]) sec = int(m["sec"]) - result = datetime(year, month, day, hour, min, sec, tzinfo=timezone.utc) + result = datetime(year, month, day, hour, min, sec, tzinfo=UTC) return int(result.timestamp()) except Exception as exc: raise ValueError("%r is not a valid date" % date) from exc |
