From b3eccc8a798847a6f405b65048acfb7ca74944d0 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 18 Nov 2014 08:37:37 +1100 Subject: [PATCH] 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. --- mcs/class/System.Core/System/TimeZoneInfo.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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 } -- 2.25.1