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:
parent
b209518089
commit
a04565845a
@ -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)
|
||||
|
||||
|
@ -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'."""
|
||||
|
Loading…
Reference in New Issue
Block a user