[Mono-dev] TimeZoneInfo.Local on Windows

Rodrigo Kumpera kumpera at gmail.com
Mon Jan 9 07:28:31 EST 2012


Hi Jonathan,

Do you mind filling a bug report for this? Or, if you have a working patch
for it, please do a pull request on github and I'll merge is promptly.

On Tue, Jan 3, 2012 at 9:05 PM, Jonathan Shore <jonathan.shore at gmail.com>wrote:

> I should also mention that this in an embedded application (so I cannot
> use the MS VM).  I have tried running this as a pure C# test app just to
> make sure is not a problem with my embedding.  Hence, need to either fix or
> avoid using this part of the API.
>
> On Jan 3, 2012, at 6:02 PM, Jonathan Shore wrote:
>
> So I have a mono application which works fine on OSX and Linux that uses
> System.TimeZoneInfo.Local, amongst other TimeZoneInfo facilities.
>
> On windows calling TimeZoneInfo.Local throws a TimeZoneNotFoundException.
>
> Looking at the class library code in
> "mcs/class/System.Core/System/TimeZoneInfo.cs" it is clear why this will
> throw an exception:
>
> public static TimeZoneInfo Local {
> 	get {
> 		if (local == null) {
> #if MONODROID
> 			local = ZoneInfoDB.Default;
> #elif MONOTOUCH
> 			using (Stream stream = GetMonoTouchDefault ()) {
> 				return BuildFromStream ("Local", stream);
> 			}
> #elif LIBC
> 			try {
> 				local = FindSystemTimeZoneByFileName ("Local", "/etc/localtime");	
> 			} catch {
> 				try {
> 					local = FindSystemTimeZoneByFileName ("Local", Path.Combine (TimeZoneDirectory, "localtime"));				} catch {
> 					throw new TimeZoneNotFoundException ();
> 				}
> 			}
> #else
> 			throw new TimeZoneNotFoundException ();
> #endif
> 		}
> 		return local;
> 	}
> }
>
> I noticed that there is windows specific code to find the time zone info
> in the registry for FindSystemTimeZoneById(). Is there not a setting in
> the registry which indicates which of these timezones is local?
>
> The code looks broken for windows, proper on unix variants, and covered on
> Andriod and iOS.
>
> Any pointers / comments on a fix or workaround for this?
>
> Jonathan
>
>
>
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120109/23862636/attachment-0001.html 


More information about the Mono-devel-list mailing list