Skip to content

Sign sub-hour UTC offsets - #1868

Closed
SimonCropp wants to merge 1 commit into
fix-negative-offset-culturefrom
fix-negative-subhour-offset
Closed

Sign sub-hour UTC offsets#1868
SimonCropp wants to merge 1 commit into
fix-negative-offset-culturefrom
fix-negative-subhour-offset

Conversation

@SimonCropp

@SimonCropp SimonCropp commented Aug 17, 2026

Copy link
Copy Markdown
Member

GetDateOffset took the sign from the hour component. For an offset of less than an hour that component is zero, so TimeSpan.FromMinutes(-30) rendered as 0-30 while 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 in GetDateOffset, so this is stacked to avoid a conflict. It keeps that PR's FormattableString.Invariant style 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.SubHourOffsets covers both signs and asserts the two no longer render the same. Full Verify.Tests passes on the rebased branch: 1305.

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
SimonCropp force-pushed the fix-negative-subhour-offset branch from f1cad32 to 863e7ed Compare August 17, 2026 12:21
@SimonCropp
SimonCropp changed the base branch from fix-offset-culture to fix-negative-offset-culture August 17, 2026 12:21
@SimonCropp
SimonCropp deleted the branch fix-negative-offset-culture August 17, 2026 13:33
@SimonCropp SimonCropp closed this Aug 17, 2026
@SimonCropp

Copy link
Copy Markdown
Member Author

Superseded by #1872: GitHub closed this automatically when the base branch (#1854) was deleted on merge, and a closed PR cannot be reopened or retargeted once its base is gone. #1872 is the same commit rebased onto main.

This was referenced Aug 26, 2026
This was referenced Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant