diff options
author | Carlton Gibson <carlton.gibson@noumenal.es> | 2021-09-09 12:56:54 +0200 |
---|---|---|
committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2021-09-09 12:56:54 +0200 |
commit | 84cb8fd4394c7080c9294974f1c4b0f733c0cdf0 (patch) | |
tree | bc6040351e34cb7e4ed826f259721be7c4d9724a /django/utils/timezone.py | |
parent | dad1f9d3fd950e0627d2eeef6e37a2fa34931ba2 (diff) | |
download | django-make-zoneinfo-default-timezone-implementation.tar.gz |
Deprecation of is_dst params.make-zoneinfo-default-timezone-implementation
Release notes and deprecation.txt pending.
Diffstat (limited to 'django/utils/timezone.py')
-rw-r--r-- | django/utils/timezone.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/django/utils/timezone.py b/django/utils/timezone.py index 940095868d..0c95416400 100644 --- a/django/utils/timezone.py +++ b/django/utils/timezone.py @@ -3,6 +3,7 @@ Timezone-related classes and functions. """ import functools +import warnings try: import zoneinfo @@ -15,6 +16,7 @@ from datetime import datetime, timedelta, timezone, tzinfo from asgiref.local import Local from django.conf import settings +from django.utils.deprecation import RemovedInDjango50Warning __all__ = [ # noqa: F822 RemovedInDjango50Warning 'utc', 'get_fixed_timezone', @@ -25,6 +27,9 @@ __all__ = [ # noqa: F822 RemovedInDjango50Warning 'is_aware', 'is_naive', 'make_aware', 'make_naive', ] +# RemovedInDjango50Warning +IS_DST_PASSED = object() + # RemovedInDjango50Warning # This code has two purposes. @@ -248,8 +253,16 @@ def is_naive(value): return value.utcoffset() is None -def make_aware(value, timezone=None, is_dst=None): +def make_aware(value, timezone=None, is_dst=IS_DST_PASSED): """Make a naive datetime.datetime in a given time zone aware.""" + if is_dst is IS_DST_PASSED: + is_dst = None + else: + warnings.warn( + 'The is_dst argument to make_aware() is deprecated as it has no ' + 'effect with zoneinfo time zones.', + RemovedInDjango50Warning + ) if timezone is None: timezone = get_current_timezone() if _is_pytz_zone(timezone): |