diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs index 583212906e68c1..0be2c6282eef96 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs @@ -934,9 +934,9 @@ public bool HasSameRules(TimeZoneInfo other) AdjustmentRule[]? currentRules = _adjustmentRules; AdjustmentRule[]? otherRules = other._adjustmentRules; - if (currentRules is null || otherRules is null) + if (currentRules is null && otherRules is null) { - return currentRules == otherRules; + return true; } return currentRules.AsSpan().SequenceEqual(otherRules); diff --git a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs index 386ca83b3771f1..3f8f93536626fd 100644 --- a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs @@ -2432,17 +2432,16 @@ public static void TimeZoneDisplayNames_Unix(TimeZoneInfo timeZone) } } - [Fact] - [PlatformSpecific(~TestPlatforms.Windows & ~TestPlatforms.Browser)] + private static bool SupportICUWithUtcAlias => PlatformDetection.IsIcuGlobalization && PlatformDetection.IsNotAppleMobile && PlatformDetection.IsNotBrowser; + + [ConditionalFact(nameof(SupportICUWithUtcAlias))] public static void UtcAliases_MapToUtc() { - TimeZoneInfo.AdjustmentRule[] expectedAdjustmentRules = TimeZoneInfo.Utc.GetAdjustmentRules(); - - foreach (var alias in s_UtcAliases) + foreach (string alias in s_UtcAliases) { TimeZoneInfo actualUtc = TimeZoneInfo.FindSystemTimeZoneById(alias); - Assert.Equal(TimeZoneInfo.Utc.BaseUtcOffset, actualUtc.BaseUtcOffset); - Assert.Equal(expectedAdjustmentRules, actualUtc.GetAdjustmentRules()); + Assert.True(TimeZoneInfo.Utc.HasSameRules(actualUtc)); + Assert.True(actualUtc.HasSameRules(TimeZoneInfo.Utc)); } }