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()
22
22
[ TestCase ( "2021-01-01T12:00:00Z" , "yyyy-MM-ddTHH:mm:ssZ" , "2021-01-01T12:00:00Z" ) ]
23
23
public void TryFormat_ValidDateFormats_ReturnsExpectedResult ( string input , string format , string expected )
24
24
{
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
+
26
36
var sut = new DateFormatter ( ) ;
27
37
var result = sut . TryFormat ( date , format , out var formatted ) ;
28
38
result . ShouldBeTrue ( ) ;
You can’t perform that action at this time.
0 commit comments