[mscorlib/Android] TimeZoneInfo.Local.Id should NOT be "Local".
authorJonathan Pryor <jonpryor@vt.edu>
Fri, 5 Dec 2014 18:23:51 +0000 (13:23 -0500)
committerJonathan Pryor <jonpryor@vt.edu>
Fri, 5 Dec 2014 18:36:04 +0000 (13:36 -0500)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=24742
Context: Commit f7fd52ad
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=24958

The logic of Commit f7fd52ad was 'Desktop Mono returns "Local" from
TimeZoneInfo.Local.Id, so surely Xamarin.Android should', predicated
in part on the assumption that whatever Desktop Mono does should be
the same as what Desktop .NET does.

This assumption wasn't verified, and is in fact wrong; Desktop .NET
doesn't return "Local" from TimeZoneInfo.Local.Id, it returns an
actual identifier.

The reason why Desktop Mono returns "Local" is due to implementation
sanity, particularly on OS X: /etc/localtime may be a symlink OR a
copy of the timezone data, and when it's a copy there's no way to
determine the Olson ID for the timezone. Consequently, it may not be
possible to determine the TimeZone ID.

Xamarin.Android doesn't have that problem; it uses the Android
persist.sys.timezone system property value,
falling back to java.util.TimeZone.getDefault().getID() if necessary,
and thus always has access to an Olson ID.

Change TimeZoneInfo.Local.Id on Xamarin.Android to return the Olson ID
instead of "Local", partially reverting Commit f7fd52ad.

mcs/class/System.Core/System/TimeZoneInfo.Android.cs

index 72285cc0dabadf6032c97d63bafac2674df74c65..8805dfe898213aad2f9c123b06af58043c192a02 100644 (file)
@@ -539,7 +539,8 @@ namespace System {
                                        lock (_lock) {
                                                if (defaultZone != null)
                                                        return defaultZone;
-                                               return defaultZone = GetTimeZone ("Local", GetDefaultTimeZoneName ());
+                                               var id  = GetDefaultTimeZoneName ();
+                                               return defaultZone = GetTimeZone (id, id);
                                        }
                                }
                        }