Skip to content

Format UTC offsets with invariant culture - #1855

Closed
SimonCropp wants to merge 1 commit into
mainfrom
fix-offset-culture
Closed

Format UTC offsets with invariant culture#1855
SimonCropp wants to merge 1 commit into
mainfrom
fix-offset-culture

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

DateFormatter.GetDateOffset rendered the offset numbers with plain interpolation, so they used CurrentCulture while every other format call in DateFormatter passes Culture.InvariantCulture.

Under a culture whose negative sign is not - (for example ar-SA, which uses U+061C followed by -), a DateTimeOffset parameter with a negative offset produced a parameter string, and hence a file name, that never matched a snapshot committed from an en-US machine. The same value also leaked into snapshot content via Convert when date scrubbing is off.

All four format calls now go through Culture.InvariantCulture. Output is unchanged for cultures that already use the invariant signs.

Added DateFormatterTests.OffsetIsNotAffectedByCurrentCulture, which formats under a culture with a custom negative sign. It fails on main and passes with this change. Full Verify.Tests suite passes.

GetDateOffset used plain interpolation, so the numbers were rendered with
CurrentCulture while the rest of DateFormatter uses InvariantCulture. Under a
culture with a non-ascii negative sign (for example ar-SA, which uses
U+061C followed by "-") a DateTimeOffset with a negative offset produced a
parameter string, and hence a file name, that never matched a snapshot
committed from an en-US machine. The same value also leaked into snapshot
content via Convert when date scrubbing is off.
@SimonCropp SimonCropp added this to the 32.0.0 milestone Aug 17, 2026
@SimonCropp

Copy link
Copy Markdown
Member Author

Duplicate of #1854, which covers the same fix with a wider theory (all five branches, including zero) and uses the real sv-SE U+2212 sign rather than an invented one. Closing in favour of that.

#1868 (sub-hour offsets) was stacked on this branch and is being rebased onto fix-negative-offset-culture.

@SimonCropp SimonCropp closed this Aug 17, 2026
This was referenced Aug 26, 2026
This was referenced Aug 27, 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