-
Notifications
You must be signed in to change notification settings - Fork 461
Improve handling of no-inheritance-marker in timezone data #1194
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes #1192 (but uncovers another bug)
|
If you aren't in a rush to merge this, I will take a look later this week :) |
tomasr8
left a comment
There was a problem hiding this 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" |
There was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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 😅
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.