Sign sub-hour UTC offsets - #1868
Closed
SimonCropp wants to merge 1 commit into
Closed
Conversation
GetDateOffset took the sign from the hour component, which is zero for an offset of less than an hour, so TimeSpan.FromMinutes(-30) rendered as 0-30 while its positive twin rendered as +0-30. The sign now comes from the offset itself and the components are rendered unsigned. Only reachable with a constructed offset: no real timezone sits in that range.
SimonCropp
force-pushed
the
fix-negative-subhour-offset
branch
from
August 17, 2026 12:21
f1cad32 to
863e7ed
Compare
SimonCropp
changed the base branch from
fix-offset-culture
to
fix-negative-offset-culture
August 17, 2026 12:21
Member
Author
This was referenced Aug 26, 2026
This was referenced Aug 28, 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.
GetDateOffsettook the sign from the hour component. For an offset of less than an hour that component is zero, soTimeSpan.FromMinutes(-30)rendered as0-30while its positive twin rendered+0-30— the two are indistinguishable by sign, and a negative offset silently reads as positive.The sign now comes from the offset as a whole and the components are rendered unsigned. Every other case renders exactly as before:
-1-30,-5,+1-30,+5,+0.Only reachable with a constructed offset, since no real timezone sits in that range.
Based on #1854, not
main— both rewrite the same four returns inGetDateOffset, so this is stacked to avoid a conflict. It keeps that PR'sFormattableString.Invariantstyle and its theory test untouched; the culture pinning still matters for the digits, and the sign is now a literal rather than a formatted negative number, which the comment there has been updated to say.DateFormatterTests.SubHourOffsetscovers both signs and asserts the two no longer render the same. FullVerify.Testspasses on the rebased branch: 1305.