Format UTC offsets with invariant culture

Closed
SI
3mo ago
+39-9

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.