Skip to content

Commit 1a6788a

Browse files
UnityAlexjoncham
authored andcommitted
Fixing a corner case where an invalid timezone on windows would throw a
TimeZoneNotFoundException. Added a catch to allow mono to try the WinRT fallback which appears to work even when there is an invalid timezone value in the registry.
1 parent 87e9e85 commit 1a6788a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mcs/class/corlib/System/TimeZoneInfo.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,13 @@ static TimeZoneInfo CreateLocal ()
165165
if (string.IsNullOrEmpty(name))
166166
name = GetLocalTimeZoneKeyNameWin32Fallback();
167167
if (name != null)
168-
return TimeZoneInfo.FindSystemTimeZoneById (name);
168+
{
169+
try{
170+
return TimeZoneInfo.FindSystemTimeZoneById (name);
171+
} catch (TimeZoneNotFoundException) {
172+
return GetLocalTimeZoneInfoWinRTFallback();
173+
}
174+
}
169175
} else if (IsWindows) {
170176
return GetLocalTimeZoneInfoWinRTFallback ();
171177
}

0 commit comments

Comments
 (0)