Skip to content

Conversation

@akx
Copy link
Member

@akx akx commented Mar 4, 2025

Fixes #1192 – in a way:

As far as I can tell, there's no well-specified operation called "get timezone name" in the TR35 spec, so doing what we do here (ending up using the location) is... okay for now, at least better than returning ∅∅∅.

However, this uncovers a bug in how we fallback timezone formatting in this specific case, for which I added an xfailing test.

There's also a new janky C++ tool that lets one format times in various TZes and locales and formats using ICU4C.

@akx akx requested a review from tomasr8 March 4, 2025 13:09
@codecov
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.71%. Comparing base (d9a257e) to head (a1b0e8b).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1194      +/-   ##
==========================================
+ Coverage   91.68%   91.71%   +0.02%     
==========================================
  Files          27       27              
  Lines        4691     4693       +2     
==========================================
+ Hits         4301     4304       +3     
+ Misses        390      389       -1     
Flag Coverage Δ
macos-14-3.10 90.75% <100.00%> (+0.02%) ⬆️
macos-14-3.11 90.68% <100.00%> (+0.02%) ⬆️
macos-14-3.12 90.90% <100.00%> (+0.02%) ⬆️
macos-14-3.13 90.90% <100.00%> (+0.02%) ⬆️
macos-14-3.8 90.61% <100.00%> (+0.02%) ⬆️
macos-14-3.9 90.68% <100.00%> (+0.02%) ⬆️
macos-14-pypy3.10 90.75% <100.00%> (+0.02%) ⬆️
ubuntu-24.04-3.10 90.77% <100.00%> (+0.02%) ⬆️
ubuntu-24.04-3.11 90.70% <100.00%> (+0.02%) ⬆️
ubuntu-24.04-3.12 90.92% <100.00%> (+0.02%) ⬆️
ubuntu-24.04-3.13 90.92% <100.00%> (+0.02%) ⬆️
ubuntu-24.04-3.8 90.63% <100.00%> (+0.02%) ⬆️
ubuntu-24.04-3.9 90.70% <100.00%> (+0.02%) ⬆️
ubuntu-24.04-pypy3.10 90.56% <100.00%> (+0.02%) ⬆️
windows-2022-3.10 90.76% <100.00%> (+0.02%) ⬆️
windows-2022-3.11 90.69% <100.00%> (+0.02%) ⬆️
windows-2022-3.12 90.91% <100.00%> (+0.02%) ⬆️
windows-2022-3.13 90.91% <100.00%> (+0.02%) ⬆️
windows-2022-3.8 90.73% <100.00%> (+0.02%) ⬆️
windows-2022-3.9 90.69% <100.00%> (+0.02%) ⬆️
windows-2022-pypy3.10 90.76% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomasr8
Copy link
Member

tomasr8 commented Mar 5, 2025

If you aren't in a rush to merge this, I will take a look later this week :)

Copy link
Member

@tomasr8 tomasr8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not much of a c++ person, but the tz changes look reasonable to me 👍

tz = timezone_getter("Pacific/Honolulu")
dt = _localize(tz, datetime(2025, 3, 4, 13, 53, tzinfo=UTC))
assert dates.format_datetime(dt, "YYYY-MM-dd H:mm z", locale="en_US") == "2025-03-04 3:53 HST"
assert dates.format_datetime(dt, "YYYY-MM-dd H:mm z", locale="en_GB") == "2025-03-04 3:53 GMT-10"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some digging and we get Hawaii-Aleutian Standard Time instead of GMT-10 here because of this fallback to the long tz name:

babel/babel/dates.py

Lines 659 to 662 in 2b93a4a

if width == 'short' and name == NO_INHERITANCE_MARKER:
# If the short form is marked no-inheritance,
# try to fall back to the long name instead.
name = metazone_info.get('long', {}).get(zone_variant)

When I get rid of it, get_timezone_gmt is used instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, I should've mentioned I also found the culprit, but it's out of scope for this PR 😅

@akx akx merged commit 2e56a2a into master Mar 17, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad short british timezone name for Honolulu

3 participants