Skip to content

Format UTC offsets with invariant culture - #1908

Closed
SimonCropp wants to merge 2 commits into
mainfrom
fix-offset-culture
Closed

Format UTC offsets with invariant culture#1908
SimonCropp wants to merge 2 commits into
mainfrom
fix-offset-culture

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

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.

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 33.0.0 milestone Aug 29, 2026
# Conflicts:
#	docs/type-to-string-mapping.md
#	src/Verify.Tests/DateFormatterTests.cs
#	src/Verify/Serialization/DateFormatter_DateTimeOffset.cs
#	src/todo.md
@SimonCropp SimonCropp closed this Aug 29, 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