Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libs][Unix] Fix UTC alias lookup #88641

Merged
merged 9 commits into from
Jul 13, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,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))]
Expand Down