[profiles] Fix MOBILE assemblies and tests compilation + Rename MOBILE to AOT_HYBRID
[mono.git] / mcs / class / corlib / System / TimeZoneInfo.cs
index 96a1150368cb076b8b0c29edf6ce9575e6720eb6..b64e180f7e06aec98191dc6729acd83db8a48dae 100644 (file)
@@ -105,10 +105,10 @@ namespace System
 
                        try {
                                ret = readlink (path, buf, buf.Length);
-                       } catch (DllNotFoundException e) {
+                       } catch (DllNotFoundException) {
                                readlinkNotFound = true;
                                return null;
-                       } catch (EntryPointNotFoundException e) {
+                       } catch (EntryPointNotFoundException) {
                                readlinkNotFound = true;
                                return null;
                        }
@@ -149,7 +149,7 @@ namespace System
                        return true;
                }
 
-#if !MOBILE || MOBILE_STATIC
+#if !MONODROID && !MONOTOUCH && !XAMMAC
                static TimeZoneInfo CreateLocal ()
                {
 #if !MOBILE_STATIC
@@ -237,7 +237,7 @@ namespace System
                        throw new NotImplementedException ("This method is not implemented for this platform");
 #endif
                }
-#endif
+#endif // !MONODROID && !MONOTOUCH && !XAMMAC
 
                string standardDisplayName;
                public string StandardName {
@@ -273,7 +273,7 @@ namespace System
 #endif
                private AdjustmentRule [] adjustmentRules;
 
-#if !MOBILE || MOBILE_STATIC
+#if !MOBILE || !MOBILE_STATIC
                /// <summary>
                /// Determine whether windows of not (taken Stephane Delcroix's code)
                /// </summary>
@@ -330,7 +330,7 @@ namespace System
                        }
                }
 #endif
-#endif
+#endif // !MOBILE || !MOBILE_STATIC
 
                private static bool TryAddTicks (DateTime date, long ticks, out DateTime result, DateTimeKind kind = DateTimeKind.Unspecified)
                {
@@ -965,12 +965,17 @@ namespace System
                        } else {
                                AdjustmentRule first = null, last = null;
 
+                               // Rule start/end dates are either very specific or very broad depending on the platform
+                               //   2015-10-04..2016-04-03 - Rule for a time zone in southern hemisphere on non-Windows platforms
+                               //   2016-03-27..2016-10-03 - Rule for a time zone in northern hemisphere on non-Windows platforms
+                               //   0001-01-01..9999-12-31 - Rule for a time zone on Windows
+
                                foreach (var rule in GetAdjustmentRules ()) {
-                                       if (rule.DateStart.Year != year && rule.DateEnd.Year != year)
+                                       if (rule.DateStart.Year > year || rule.DateEnd.Year < year)
                                                continue;
-                                       if (rule.DateStart.Year == year)
+                                       if (rule.DateStart.Year <= year && (first == null || rule.DateStart.Year > first.DateStart.Year))
                                                first = rule;
-                                       if (rule.DateEnd.Year == year)
+                                       if (rule.DateEnd.Year >= year && (last == null || rule.DateEnd.Year < last.DateEnd.Year))
                                                last = rule;
                                }