diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs index 992035b92df60..2524b4fd53606 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs @@ -33,8 +33,8 @@ private static bool IsUtcAlias (string id) case 69: // e case 101: // E return string.Equals(id, "Etc/UTC", StringComparison.OrdinalIgnoreCase) || + string.Equals(id, "Etc/UCT", StringComparison.OrdinalIgnoreCase) || string.Equals(id, "Etc/Universal", StringComparison.OrdinalIgnoreCase) || - string.Equals(id, "Etc/UTC", StringComparison.OrdinalIgnoreCase) || string.Equals(id, "Etc/Zulu", StringComparison.OrdinalIgnoreCase); case 85: // u case 117: // U diff --git a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs index 18c033afd2ade..386ca83b3771f 100644 --- a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs @@ -2334,6 +2334,14 @@ public static IEnumerable SystemTimeZonesTestData() yield return new object[] { tz }; } } + + if (!PlatformDetection.IsBrowser) + { + foreach (string alias in s_UtcAliases) + { + yield return new object[] { TimeZoneInfo.FindSystemTimeZoneById(alias) }; + } + } } } @@ -2424,6 +2432,20 @@ public static void TimeZoneDisplayNames_Unix(TimeZoneInfo timeZone) } } + [Fact] + [PlatformSpecific(~TestPlatforms.Windows & ~TestPlatforms.Browser)] + public static void UtcAliases_MapToUtc() + { + TimeZoneInfo.AdjustmentRule[] expectedAdjustmentRules = TimeZoneInfo.Utc.GetAdjustmentRules(); + + foreach (var alias in s_UtcAliases) + { + TimeZoneInfo actualUtc = TimeZoneInfo.FindSystemTimeZoneById(alias); + Assert.Equal(TimeZoneInfo.Utc.BaseUtcOffset, actualUtc.BaseUtcOffset); + Assert.Equal(expectedAdjustmentRules, actualUtc.GetAdjustmentRules()); + } + } + [ActiveIssue("https://github.com/dotnet/runtime/issues/19794", TestPlatforms.AnyUnix)] [Theory] [MemberData(nameof(SystemTimeZonesTestData))]