From: Alistair Leslie-Hughes Date: Mon, 17 Nov 2014 21:37:37 +0000 (+1100) Subject: Improved support for TimeZoneInfo under windows. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=b3eccc8a798847a6f405b65048acfb7ca74944d0;p=mono.git Improved support for TimeZoneInfo under windows. When cross compiling with gcc, LIBC is defined and thus never checks the registry for the timezone information. This change is released under the MIT license. --- diff --git a/mcs/class/System.Core/System/TimeZoneInfo.cs b/mcs/class/System.Core/System/TimeZoneInfo.cs index 354b47a2a06..9e169efc579 100644 --- a/mcs/class/System.Core/System/TimeZoneInfo.cs +++ b/mcs/class/System.Core/System/TimeZoneInfo.cs @@ -116,7 +116,14 @@ namespace System using (Stream stream = GetMonoTouchData (null)) { return BuildFromStream ("Local", stream); } -#elif LIBC +#else + if (IsWindows && LocalZoneKey != null) { + string name = (string)LocalZoneKey.GetValue ("TimeZoneKeyName"); + name = TrimSpecial (name); + if (name != null) + return TimeZoneInfo.FindSystemTimeZoneById (name); + } + var tz = Environment.GetEnvironmentVariable ("TZ"); if (tz != null) { if (tz == String.Empty) @@ -137,15 +144,6 @@ namespace System return null; } } -#else - if (IsWindows && LocalZoneKey != null) { - string name = (string)LocalZoneKey.GetValue ("TimeZoneKeyName"); - name = TrimSpecial (name); - if (name != null) - return TimeZoneInfo.FindSystemTimeZoneById (name); - } - - return null; #endif }