Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/System.Runtime/tests/System/TimeZoneInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2221,12 +2221,23 @@ public static void TimeZoneInfo_DisplayNameStartsWithOffset()
{
Assert.False(string.IsNullOrWhiteSpace(tzi.StandardName));
Assert.Matches(@"^\(UTC(\+|-)[0-9]{2}:[0-9]{2}\) \S.*", tzi.DisplayName);

// see https://github.com/dotnet/corefx/pull/33204#issuecomment-438782500
if (PlatformDetection.IsNotWindowsNanoServer && !PlatformDetection.IsWindows7)
{
string offset = Regex.Match(tzi.DisplayName, @"(-|)[0-9]{2}:[0-9]{2}").Value;
Assert.True(tzi.BaseUtcOffset == TimeSpan.Parse(offset), $"{offset} != {tzi.BaseUtcOffset}, dn:{tzi.DisplayName}, sn:{tzi.DisplayName}");
TimeSpan ts = TimeSpan.Parse(offset);
if (tzi.BaseUtcOffset != ts && tzi.Id.IndexOf("Morocco", StringComparison.Ordinal) >= 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there some bug for OS to fix this?

{
// Windows data can report display name with UTC+01:00 offset which is not matching the actual BaseUtcOffset.
// We special case this in the test to avoid the test failures like:
// 01:00 != 00:00:00, dn:(UTC+01:00) Casablanca, sn:Morocco Standard Time
Assert.True(tzi.BaseUtcOffset == new TimeSpan(0, 0, 0), $"{offset} != {tzi.BaseUtcOffset}, dn:{tzi.DisplayName}, sn:{tzi.StandardName}");
}
else
{
Assert.True(tzi.BaseUtcOffset == ts, $"{offset} != {tzi.BaseUtcOffset}, dn:{tzi.DisplayName}, sn:{tzi.StandardName}");
}
}
}
}
Expand Down