1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Refs #34233 -- Referenced isocalendar() results by names not indexes.

isocalendar() returns a namedtuple() instead of tuple in Python 3.9+
This commit is contained in:
Mariusz Felisiak 2023-01-18 12:57:54 +01:00 committed by GitHub
parent b209518089
commit a04565845a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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'."""