summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/dateparse.py2
-rw-r--r--django/utils/feedgenerator.py2
-rw-r--r--django/utils/http.py6
-rw-r--r--django/utils/timezone.py4
-rw-r--r--django/utils/version.py2
5 files changed, 8 insertions, 8 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py
index 5cedd1affa..42c2684d7c 100644
--- a/django/utils/dateparse.py
+++ b/django/utils/dateparse.py
@@ -118,7 +118,7 @@ def parse_datetime(value):
kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0")
tzinfo = kw.pop("tzinfo")
if tzinfo == "Z":
- tzinfo = datetime.timezone.utc
+ tzinfo = datetime.UTC
elif tzinfo is not None:
offset_mins = int(tzinfo[-2:]) if len(tzinfo) > 3 else 0
offset = 60 * int(tzinfo[1:3]) + offset_mins
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index fae3271430..e52720a61e 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -277,7 +277,7 @@ class SyndicationFeed:
if latest_date is None or item_date > latest_date:
latest_date = item_date
- return latest_date or datetime.datetime.now(tz=datetime.timezone.utc)
+ return latest_date or datetime.datetime.now(tz=datetime.UTC)
class Enclosure:
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
diff --git a/django/utils/timezone.py b/django/utils/timezone.py
index 102562b254..6d6cbf6d8f 100644
--- a/django/utils/timezone.py
+++ b/django/utils/timezone.py
@@ -5,7 +5,7 @@ Timezone-related classes and functions.
import functools
import zoneinfo
from contextlib import ContextDecorator
-from datetime import datetime, timedelta, timezone, tzinfo
+from datetime import UTC, datetime, timedelta, timezone, tzinfo
from asgiref.local import Local
@@ -201,7 +201,7 @@ def now():
"""
Return an aware or naive datetime.datetime, depending on settings.USE_TZ.
"""
- return datetime.now(tz=timezone.utc if settings.USE_TZ else None)
+ return datetime.now(tz=UTC if settings.USE_TZ else None)
# By design, these four functions don't perform any checks on their arguments.
diff --git a/django/utils/version.py b/django/utils/version.py
index 4ef8cfbcfe..2bb650ac89 100644
--- a/django/utils/version.py
+++ b/django/utils/version.py
@@ -96,7 +96,7 @@ def get_git_changeset():
text=True,
)
timestamp = git_log.stdout
- tz = datetime.timezone.utc
+ tz = datetime.UTC
try:
timestamp = datetime.datetime.fromtimestamp(int(timestamp), tz=tz)
except ValueError: