File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/GitVersion.Core.Tests/Formatting Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,17 @@ public void TryFormat_NullValue_ReturnsFalse()
2222 [ TestCase ( "2021-01-01T12:00:00Z" , "yyyy-MM-ddTHH:mm:ssZ" , "2021-01-01T12:00:00Z" ) ]
2323 public void TryFormat_ValidDateFormats_ReturnsExpectedResult ( string input , string format , string expected )
2424 {
25- var date = DateTime . Parse ( input , CultureInfo . InvariantCulture ) ;
25+ // For UTC datetime strings, parse as UTC to ensure consistent behavior across timezones
26+ DateTime date ;
27+ if ( input . EndsWith ( "Z" ) )
28+ {
29+ date = DateTime . Parse ( input , CultureInfo . InvariantCulture , DateTimeStyles . AdjustToUniversal ) ;
30+ }
31+ else
32+ {
33+ date = DateTime . Parse ( input , CultureInfo . InvariantCulture ) ;
34+ }
35+
2636 var sut = new DateFormatter ( ) ;
2737 var result = sut . TryFormat ( date , format , out var formatted ) ;
2838 result . ShouldBeTrue ( ) ;
You can’t perform that action at this time.
0 commit comments