diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2022-03-23 12:15:36 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-24 06:29:50 +0100 |
| commit | bb61f0186d5c490caa44f3e3672d81e14414d33c (patch) | |
| tree | 71e682d415e4640fd1e950af0e4921b2af57ea60 /django/utils | |
| parent | 1cf60ce6017d904024ee132f7edae0b4b821a954 (diff) | |
Refs #32365 -- Removed internal uses of utils.timezone.utc alias.
Remaining test case ensures that uses of the alias are mapped
canonically by the migration writer.
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/dateparse.py | 4 | ||||
| -rw-r--r-- | django/utils/feedgenerator.py | 3 | ||||
| -rw-r--r-- | django/utils/timesince.py | 4 | ||||
| -rw-r--r-- | django/utils/timezone.py | 2 |
4 files changed, 6 insertions, 7 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py index 2e6a260a4f..08651f57ad 100644 --- a/django/utils/dateparse.py +++ b/django/utils/dateparse.py @@ -8,7 +8,7 @@ import datetime from django.utils.regex_helper import _lazy_re_compile -from django.utils.timezone import get_fixed_timezone, utc +from django.utils.timezone import get_fixed_timezone date_re = _lazy_re_compile(r"(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})$") @@ -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 = utc + tzinfo = datetime.timezone.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 5a57db19ec..31ca9a2db9 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -27,7 +27,6 @@ from io import StringIO from urllib.parse import urlparse from django.utils.encoding import iri_to_uri -from django.utils.timezone import utc from django.utils.xmlutils import SimplerXMLGenerator @@ -210,7 +209,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=utc) + return latest_date or datetime.datetime.now(tz=datetime.timezone.utc) class Enclosure: diff --git a/django/utils/timesince.py b/django/utils/timesince.py index 8a8ffb8151..3a0d4afb1a 100644 --- a/django/utils/timesince.py +++ b/django/utils/timesince.py @@ -2,7 +2,7 @@ import calendar import datetime from django.utils.html import avoid_wrapping -from django.utils.timezone import is_aware, utc +from django.utils.timezone import is_aware from django.utils.translation import gettext, ngettext_lazy TIME_STRINGS = { @@ -54,7 +54,7 @@ def timesince(d, now=None, reversed=False, time_strings=None, depth=2): if now and not isinstance(now, datetime.datetime): now = datetime.datetime(now.year, now.month, now.day) - now = now or datetime.datetime.now(utc if is_aware(d) else None) + now = now or datetime.datetime.now(datetime.timezone.utc if is_aware(d) else None) if reversed: d, now = now, d diff --git a/django/utils/timezone.py b/django/utils/timezone.py index 71b160448e..33c0440095 100644 --- a/django/utils/timezone.py +++ b/django/utils/timezone.py @@ -224,7 +224,7 @@ def now(): """ Return an aware or naive datetime.datetime, depending on settings.USE_TZ. """ - return datetime.now(tz=utc if settings.USE_TZ else None) + return datetime.now(tz=timezone.utc if settings.USE_TZ else None) # By design, these four functions don't perform any checks on their arguments. |
