Hi,

On Mon, Sep 17, 2012 at 12:56 PM, Rolf Bjarne Kvinge <[email protected]>wrote:

> Hi,
>
> On Sat, Sep 15, 2012 at 9:13 AM, Liam Houlahan <[email protected]>wrote:
>
>> Hi Everyone
>>
>> I am trying to get the current time for a specific Timezone. This
>> Timezone may not be the same as the Timezone set in the phone.
>>
>> Here is the code that I am using:
>>
>> DateTime specTime = TimeZoneInfo.ConvertTime (DateTime.Now,
>> TimeZoneInfo.FindSystemTimeZoneById("Pacific/Auckland"));
>>
>> This code works fine on my Mac running in ASP.Net but when I run it on
>> MonoTouch I get the following error:
>>
>> System.ArgumentException: Kind propery of dateTime is Local but the
>> sourceTimeZone does not equal TimeZoneInfo.Local at
>> System.TimeZoneInfo.ConvertTime (DateTime dateTime, System.TimeZoneInfo
>> sourceTimeZone, System.TimeZoneInfo destinationTimeZone) [0x00018] in
>> /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System/TimeZoneInfo.cs:179
>> at System.TimeZoneInfo.ConvertTime (DateTime dateTime, System.TimeZoneInfo
>> destinationTimeZone) [0x00000] in
>> /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System/TimeZoneInfo.cs:173
>>
>> Is this a bug in MonoTouch or should I be doing this a different way?
>>
>
> Yes, this is a bug in MonoTouch. It will be fixed in a future version of
> MonoTouch (I don't know exactly which yet though).
>
> I couldn't find any easy workaround for the moment, but you can have a
> look at the source code for TimeZoneInfo to see if you can do the
> conversion manually:
> https://github.com/mono/mono/blob/master/mcs/class/System.Core/System/TimeZoneInfo.cs#L240
>

I just created a hotfix for this issue:
https://bugzilla.xamarin.com/show_bug.cgi?id=7214#c2 - which is likely
easier :)

Rolf


>
>
I hope this helps,
> Rolf
>
>
>
>>
>> Thanks
>> Liam
>>
>> _______________________________________________
>> MonoTouch mailing list
>> [email protected]
>> http://lists.ximian.com/mailman/listinfo/monotouch
>>
>>
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to