From 9500a30178a1e838f21022e09a8a0194f554b294 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 16 Jan 2018 23:22:29 +0800 Subject: [PATCH] for some regions, specifically Asia/Singapore, the native icall returns incorrectly because the country's timezone changed. In this case in 1981 Asia/Singapore changed from +0730 to +08....Since the UTC offset changed, our logic thinks that daylight savings may have started, and the icall returns incorrect data, which causes the CreateLocalUnity function to throw. Fixing the icall is important, but for the time being we'll wrap the CreateLocalUnity function with a try catch. then fix the native icall... --- mcs/class/corlib/System/TimeZoneInfo.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mcs/class/corlib/System/TimeZoneInfo.cs b/mcs/class/corlib/System/TimeZoneInfo.cs index b6913968078..d05ff302d81 100644 --- a/mcs/class/corlib/System/TimeZoneInfo.cs +++ b/mcs/class/corlib/System/TimeZoneInfo.cs @@ -170,9 +170,15 @@ namespace System #endif #if UNITY - var localTimeZoneFallback = CreateLocalUnity(); - if(localTimeZoneFallback == null) - localTimeZoneFallback = Utc; + TimeZoneInfo localTimeZoneFallback = null; + try { + localTimeZoneFallback = CreateLocalUnity(); + } catch { + localTimeZoneFallback = null; + } + + if (localTimeZoneFallback == null) + localTimeZoneFallback = Utc; #endif var tz = Environment.GetEnvironmentVariable ("TZ"); -- GitLab