Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate get_next_timezone_transition() #852

Merged
merged 1 commit into from Apr 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions babel/dates.py
Expand Up @@ -221,11 +221,21 @@ def get_next_timezone_transition(zone=None, dt=None):
Transition information can only be provided for timezones returned by
the :func:`get_timezone` function.

This function is pending deprecation with no replacement planned in the
Babel library.

:param zone: the timezone for which the transition should be looked up.
If not provided the local timezone is used.
:param dt: the date after which the next transition should be found.
If not given the current time is assumed.
"""
warnings.warn(
"get_next_timezone_transition() is deprecated and will be "
"removed in the next version of Babel. "
"Please see https://github.com/python-babel/babel/issues/716 "
"for discussion.",
category=DeprecationWarning,
)
zone = get_timezone(zone)
dt = _get_datetime(dt).replace(tzinfo=None)

Expand Down Expand Up @@ -256,6 +266,9 @@ class TimezoneTransition(object):
"""A helper object that represents the return value from
:func:`get_next_timezone_transition`.

This class is pending deprecation with no replacement planned in the
Babel library.

:field activates:
The time of the activation of the timezone transition in UTC.
:field from_tzinfo:
Expand All @@ -268,6 +281,13 @@ class TimezoneTransition(object):
"""

def __init__(self, activates, from_tzinfo, to_tzinfo, reference_date=None):
warnings.warn(
"TimezoneTransition is deprecated and will be "
"removed in the next version of Babel. "
"Please see https://github.com/python-babel/babel/issues/716 "
"for discussion.",
category=DeprecationWarning,
)
self.activates = activates
self.from_tzinfo = from_tzinfo
self.to_tzinfo = to_tzinfo
Expand Down