Use Android-specific code to get the current system time zone
[mono.git] / mcs / class / corlib / System / AndroidPlatform.cs
index 5a2483dcc3e4a488fdced9fb979e2152b9963ba5..1b3c5a40d07fec8671385b053d0238c440931431 100644 (file)
@@ -35,6 +35,7 @@ namespace System {
 
                static readonly Func<SynchronizationContext> getDefaultSyncContext;
                static readonly Func<string> getDefaultTimeZone;
+               static readonly Func<TimeZone> getCurrentSystemTimeZone;
 
                static AndroidPlatform ()
                {
@@ -49,6 +50,12 @@ namespace System {
                                                Type.GetType ("Android.Runtime.AndroidEnvironment, Mono.Android", true)
                                                .GetMethod ("GetDefaultTimeZone", 
                                                        System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic));
+
+                       getCurrentSystemTimeZone = (Func<TimeZone>)
+                               Delegate.CreateDelegate (typeof(Func<TimeZone>), 
+                                               Type.GetType ("Android.Runtime.AndroidEnvironment, Mono.Android", true)
+                                               .GetMethod ("GetCurrentSystemTimeZone", 
+                                                       System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic));
                }
 
                internal static SynchronizationContext GetDefaultSyncContext ()
@@ -60,6 +67,13 @@ namespace System {
                {
                        return getDefaultTimeZone ();
                }
+
+               internal static TimeZone GetCurrentSystemTimeZone ()
+               {
+                       if (getCurrentSystemTimeZone == null)
+                               return null;
+                       return getCurrentSystemTimeZone ();
+               }
        }
 }
 #endif