summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-18 12:57:54 +0100
committerGitHub <noreply@github.com>2023-01-18 12:57:54 +0100
commita04565845ae3e766a1a4ec827a6e1f4fac335c3a (patch)
treee5ca83f2e39e5269153013cf47ac26a98f6eb547 /django
parentb209518089131c6b4afd18b1d9c320ba3521c5ab (diff)
downloaddjango-a04565845ae3e766a1a4ec827a6e1f4fac335c3a.tar.gz
Refs #34233 -- Referenced isocalendar() results by names not indexes.
isocalendar() returns a namedtuple() instead of tuple in Python 3.9+
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/sqlite3/_functions.py4
-rw-r--r--django/utils/dateformat.py4
2 files changed, 4 insertions, 4 deletions
diff --git a/django/db/backends/sqlite3/_functions.py b/django/db/backends/sqlite3/_functions.py
index 9c1ef4a30a..7e86950f7d 100644
--- a/django/db/backends/sqlite3/_functions.py
+++ b/django/db/backends/sqlite3/_functions.py
@@ -183,11 +183,11 @@ def _sqlite_datetime_extract(lookup_type, dt, tzname=None, conn_tzname=None):
elif lookup_type == "iso_week_day":
return dt.isoweekday()
elif lookup_type == "week":
- return dt.isocalendar()[1]
+ return dt.isocalendar().week
elif lookup_type == "quarter":
return ceil(dt.month / 3)
elif lookup_type == "iso_year":
- return dt.isocalendar()[0]
+ return dt.isocalendar().year
else:
return getattr(dt, lookup_type)
diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py
index f352c99f1a..a6c315e4cf 100644
--- a/django/utils/dateformat.py
+++ b/django/utils/dateformat.py
@@ -257,7 +257,7 @@ class DateFormat(TimeFormat):
def o(self):
"ISO 8601 year number matching the ISO week number (W)"
- return self.data.isocalendar()[0]
+ return self.data.isocalendar().year
def r(self):
"RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'"
@@ -303,7 +303,7 @@ class DateFormat(TimeFormat):
def W(self):
"ISO-8601 week number of year, weeks starting on Monday"
- return self.data.isocalendar()[1]
+ return self.data.isocalendar().week
def y(self):
"""Year, 2 digits with leading zeros; e.g. '99'."""