Skip to content

Commit

Permalink
Fix TimeZoneInfo test failure (#77745)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekgh authored Nov 1, 2022
1 parent 86332e9 commit 7e2af70
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,8 +2151,7 @@ public static void ConvertTimeFromToUtc()
}

[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Expected behavior specific to Unix
public static void ConvertTimeFromToUtc_UnixOnly()
public static void ConvertTimeFromToUtcUsingCustomZone()
{
// DateTime Kind is Local
Assert.ThrowsAny<ArgumentException>(() =>
Expand Down Expand Up @@ -2181,21 +2180,13 @@ public static void ConvertTimeFromToUtc_UnixOnly()
Assert.Equal(DateTimeKind.Unspecified, convertedAmbiguous.Kind);
Assert.True(london.IsAmbiguousTime(convertedAmbiguous), $"Expected to have {convertedAmbiguous} is ambiguous");

// convert to London time and back
DateTime utc = DateTime.UtcNow;
Assert.Equal(DateTimeKind.Utc, utc.Kind);
// roundtrip check using ambiguous time.
DateTime utc = new DateTime(2022, 10, 30, 1, 47, 13, DateTimeKind.Utc);
DateTime converted = TimeZoneInfo.ConvertTimeFromUtc(utc, london);
Assert.Equal(DateTimeKind.Unspecified, converted.Kind);
DateTime back = TimeZoneInfo.ConvertTimeToUtc(converted, london);
Assert.Equal(DateTimeKind.Utc, back.Kind);

if (london.IsAmbiguousTime(converted))
{
// if the time is ambiguous this will not round trip the original value because this ambiguous time can be mapped into
// 2 UTC times. usually we return the value with the DST delta added to it.
back = back.AddTicks(-london.GetAdjustmentRules()[0].DaylightDelta.Ticks);
}

Assert.True(london.IsAmbiguousTime(converted));
Assert.Equal(utc, back);
}

Expand Down

0 comments on commit 7e2af70

Please sign in to comment.