1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #32365 -- Removed is_dst argument for various methods and functions.

Per deprecation timeline.
This commit is contained in:
Mariusz Felisiak
2023-01-09 09:52:26 +01:00
parent e6f82438d4
commit 2fad163257
8 changed files with 32 additions and 110 deletions

View File

@@ -241,18 +241,14 @@ class TruncBase(TimezoneMixin, Transform):
kind = None
tzinfo = None
# RemovedInDjango50Warning: when the deprecation ends, remove is_dst
# argument.
def __init__(
self,
expression,
output_field=None,
tzinfo=None,
is_dst=timezone.NOT_PASSED,
**extra,
):
self.tzinfo = tzinfo
self.is_dst = is_dst
super().__init__(expression, output_field=output_field, **extra)
def as_sql(self, compiler, connection):
@@ -343,7 +339,7 @@ class TruncBase(TimezoneMixin, Transform):
pass
elif value is not None:
value = value.replace(tzinfo=None)
value = timezone.make_aware(value, self.tzinfo, is_dst=self.is_dst)
value = timezone.make_aware(value, self.tzinfo)
elif not connection.features.has_zoneinfo_database:
raise ValueError(
"Database returned an invalid datetime value. Are time "
@@ -360,22 +356,16 @@ class TruncBase(TimezoneMixin, Transform):
class Trunc(TruncBase):
# RemovedInDjango50Warning: when the deprecation ends, remove is_dst
# argument.
def __init__(
self,
expression,
kind,
output_field=None,
tzinfo=None,
is_dst=timezone.NOT_PASSED,
**extra,
):
self.kind = kind
super().__init__(
expression, output_field=output_field, tzinfo=tzinfo, is_dst=is_dst, **extra
)
super().__init__(expression, output_field=output_field, tzinfo=tzinfo, **extra)
class TruncYear(TruncBase):

View File

@@ -1372,11 +1372,7 @@ class QuerySet(AltersData):
.order_by(("-" if order == "DESC" else "") + "datefield")
)
# RemovedInDjango50Warning: when the deprecation ends, remove is_dst
# argument.
def datetimes(
self, field_name, kind, order="ASC", tzinfo=None, is_dst=timezone.NOT_PASSED
):
def datetimes(self, field_name, kind, order="ASC", tzinfo=None):
"""
Return a list of datetime objects representing all available
datetimes for the given field_name, scoped to 'kind'.
@@ -1400,7 +1396,6 @@ class QuerySet(AltersData):
kind,
output_field=DateTimeField(),
tzinfo=tzinfo,
is_dst=is_dst,
),
plain_field=F(field_name),
)

View File

@@ -37,9 +37,6 @@ __all__ = [ # noqa for utc RemovedInDjango50Warning.
"make_naive",
]
# RemovedInDjango50Warning: sentinel for deprecation of is_dst parameters.
NOT_PASSED = object()
def __getattr__(name):
if name != "utc":
@@ -259,17 +256,8 @@ def is_naive(value):
return value.utcoffset() is None
def make_aware(value, timezone=None, is_dst=NOT_PASSED):
def make_aware(value, timezone=None):
"""Make a naive datetime.datetime in a given time zone aware."""
if is_dst is NOT_PASSED:
is_dst = None
else:
warnings.warn(
"The is_dst argument to make_aware(), used by the Trunc() "
"database functions and QuerySet.datetimes(), is deprecated as it "
"has no effect with zoneinfo time zones.",
RemovedInDjango50Warning,
)
if timezone is None:
timezone = get_current_timezone()
# Check that we won't overwrite the timezone of an aware datetime.