Sign sub-hour UTC offsets - #1872
Merged
Merged
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 13:41
4f6d25c to
f45f2a6
Compare
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.
Supersedes #1868, which GitHub closed automatically when its base branch (#1854) was deleted on merge. Same change, rebased onto
main.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.
Built on top of #1854, so it keeps that PR's
FormattableString.Invariantstyle and its theory test untouched. One line of its comment changed: the sign is now written as a literal rather than taken from a negative number, so the culture pinning covers the digits rather than the sign.The rebase conflicted with #1856 (
SubMillisecondTicks, merged since), which appends tests at the same point inDateFormatterTests. Purely additive — both kept.DateFormatterTests.SubHourOffsetscovers both signs and asserts the two no longer render the same. Verified with a local run of the fullappveyor.ymlbuild script in Release on the merged result: build clean, all 17 test projects pass.