Fix "GMT Standard Time" incorrectly interpreted as fixed-offset zone on Android#130340
Merged
matouskozak merged 2 commits intoJul 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Android’s TimeZoneInfo ID handling so that only true numeric-offset IDs (e.g., GMT+5, GMT-3) are treated as fixed-offset zones, allowing other GMT... Windows IDs (notably GMT Standard Time) to flow to the Windows→IANA conversion path and preserve DST semantics.
Changes:
- Tighten the Android
GetTimeZonefast-path to requireGMT+/GMT-before using the numeric-offset parser. - Add Android-only tests to validate
GMT+/-Nfixed-offset behavior and preventGMT Standard Timefrom being misclassified.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.Android.cs | Narrows the “GMT numeric offset” detection to avoid misclassifying non-offset GMT... IDs. |
| src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs | Adds Android-specific coverage for GMT+/- parsing and a regression test for GMT Standard Time DST behavior. |
Contributor
|
Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger |
44f468c to
3f86acb
Compare
Member
Author
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Jul 8, 2026
Open
…ndroid The GMT numeric offset check in GetTimeZone matched any name starting with "GMT" (e.g. "GMT Standard Time") instead of only names with a "+" or "-" after "GMT" (e.g. "GMT+5", "GMT-3"). This caused Windows time zone IDs like "GMT Standard Time" to be resolved as UTC-like fixed-offset zones with no daylight saving time, instead of falling through to the IANA lookup path (Europe/London). Fix: require name[3] to be "+" or "-" before treating as numeric offset. Added Android-specific tests for both GMT+/- offset zones and the regression case. Fixes dotnet#126943 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
3f86acb to
b7d9d18
Compare
Member
Author
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
filipnavara
approved these changes
Jul 9, 2026
This was referenced Jul 9, 2026
tarekgh
reviewed
Jul 9, 2026
tarekgh
approved these changes
Jul 9, 2026
tarekgh
left a comment
Member
There was a problem hiding this comment.
Added minor comment, LGTM otherwise.
Bare "GMT+" and "GMT-" are invalid timezone IDs. Using Length > 4 ensures there is at least one digit after the sign character, so these invalid IDs fall through to the tzdata lookup and correctly return null instead of being silently treated as UTC. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
tarekgh
approved these changes
Jul 9, 2026
This was referenced Jul 9, 2026
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.
Fixes #126943
Description
On Android,
TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time")incorrectly returns a UTC-like time zone with no daylight saving time. "GMT Standard Time" is the Windows time zone ID for Great Britain (Europe/London) which observes BST (UTC+1) in summer.Root Cause
The
GetTimeZonemethod inTimeZoneInfo.Unix.Android.cshas a check for GMT numeric offset zones (likeGMT+5,GMT-3) that only verifies the first 3 characters are "GMT":This incorrectly matches "GMT Standard Time" and treats it as a fixed-offset zone (with offset 0 from
ParseGMTNumericZone), preventing the correct fallback to the IANA lookup path.Fix
Added a check for
+or-at position 3 to ensure only actual numeric offset zone names are handled:Testing
AndroidGMTOffsetTimeZoneTest— verifies GMT+/- offset zones still work correctlyAndroidGMTNameNotMistakenForGMTOffsetTimeZoneTest— regression test verifying "GMT Standard Time" resolves with DST supportSupportsDaylightSavingTime: False, after fix returnsTruewith correct UTC+1 offset in summer