Fix local timezone offsets in get_timezone_name(None) - #1356
Open
arindamsikder wants to merge 1 commit into
Open
arindamsikder wants to merge 1 commit into
arindamsikder wants to merge 1 commit into
Conversation
akx
reviewed
Sep 29, 2026
| resulting display name will be generic, i.e. | ||
| independent of daylight savings time; if `None`, the | ||
| current date in UTC is assumed | ||
| current date and time in the local timezone is assumed |
Member
There was a problem hiding this comment.
This is a behavioral change, isn't it?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve the local timezone when resolving
get_timezone_name(None), including its GMT-offset fallback and daylight-saving-time selection.Problem
The
Nonepath creates a naive local datetime. If there is no translated timezone name,get_timezone_gmt()treats that datetime as UTC, so a local offset such asGMT+05:30becomesGMT+00:00. This causes the existingtest_get_timezone_name_miscregression to fail outside UTC.Solution
LOCALTZattached throughdatetime.now(LOCALTZ).Noneparameter documentation to reflect the established local-time behavior.No timezone database, public API, dependency, or workflow changes.
Testing
Executed on Linux/Python 3.11 in a credential-free, network-isolated Bubblewrap environment:
TZ=UTC make test PYTEST_FLAGS='-p no:cacheprovider --basetemp=/tmp/pytest': 7,837 passed, 7 skipped, 2 xfailed. One existing pytest deprecation warning remains.tests/test_dates.pyunder both UTC and Asia/Kolkata: 2,390 passed, 2 xfailed in each run.return_zone; no compatibility regression was found.ruff check --no-cache babel/dates.py tests/test_dates.pypassed.git diff --checkpassed.The full supported-Python/OS CI matrix was not run locally; upstream CI and maintainer review are still required.
Related Issue
Fixes #935.
Automation disclosure
Prepared by the Hermes autonomous engineering agent operated by Arindam Sikder (@arindamsikder), with a separate read-only automated reviewer that independently executed tests against the exact patch. This is not a claim of human maintainer approval. No automatic merge is requested or performed.
Base:
e2a17919f0eb988bfea2883b00793ca4d5d37c4fHead:
5a68e8668b6e549a3f2e6571838455978f453ef2