Improved support for TimeZoneInfo under windows.
authorAlistair Leslie-Hughes <leslie_alistair@hotmail.com>
Mon, 17 Nov 2014 21:37:37 +0000 (08:37 +1100)
committerAlistair Leslie-Hughes <leslie_alistair@hotmail.com>
Tue, 18 Nov 2014 09:46:15 +0000 (20:46 +1100)
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

index 354b47a2a064188a19b2a44c4d31f1dec64308c9..9e169efc579d5157f5e27c62284137072d99aacc 100644 (file)
@@ -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
                }