From 142e70fdcc09cb712e7910d57ea82f260c4583c3 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 17 Sep 2012 11:34:48 +0200 Subject: [PATCH] TimeZoneInfo.Local must be cached, otherwise reference comparisons fail later on. This fixes an issue reported here: http://lists.ximian.com/pipermail/monotouch/2012-September/011784.html --- mcs/class/System.Core/System/TimeZoneInfo.cs | 2 +- mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mcs/class/System.Core/System/TimeZoneInfo.cs b/mcs/class/System.Core/System/TimeZoneInfo.cs index 0a4dc0613840b..139a9ead34da3 100644 --- a/mcs/class/System.Core/System/TimeZoneInfo.cs +++ b/mcs/class/System.Core/System/TimeZoneInfo.cs @@ -89,7 +89,7 @@ public sealed partial class TimeZoneInfo : IEquatable, ISerializab local = ZoneInfoDB.Default; #elif MONOTOUCH using (Stream stream = GetMonoTouchDefault ()) { - return BuildFromStream ("Local", stream); + local = BuildFromStream ("Local", stream); } #elif LIBC try { diff --git a/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs b/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs index ed20b5e289bfd..06de33e9ab726 100644 --- a/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs +++ b/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs @@ -384,6 +384,15 @@ public void ConvertFromToUtc () Assert.AreEqual (utc, back); } + + [Test] + public void ConvertToTimeZone () + { + if (Environment.OSVersion.Platform != PlatformID.Unix) + return; + + TimeZoneInfo.ConvertTime (DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Pacific/Auckland")); + } } [TestFixture]