carloseberhardt
carloseberhardt

Reputation: 93

Is there a difference between TimeZoneInfo instances for .NET 3.5 on Windows compared to Mono on OS X?

I'm trying to call EWS (Exchange version 2007 SP1) using Mono on OS X. I can connect to the service and authenticate, but any calls I try to make result in an exception as follows:

Microsoft.Exchange.WebServices.Data.ServiceResponseException has been thrown "A time zone with the specified ID could not be found."

I've tried specifying several different IDs and all result in the same response. I'm starting to wonder if the TZI ids themselves are different between platforms. If so, does anyone know how to resolve the differences?

Upvotes: 3

Views: 1346

Answers (1)

carloseberhardt
carloseberhardt

Reputation: 93

There is indeed a difference between time zone ids on the two systems. I used the following code to loop through the timezones on each system and note the differences for the timezones I was interested in using:

    foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones()){
                    Console.WriteLine("{0}, {1}, {2}, {3}", tz.Id,
                           tz.DisplayName, tz.StandardName, tz.DaylightName);

            }

Then I used the CreateCustomTimeZone method to build an instance that mimicked the Windows settings:

    TimeZoneInfo newtz = TimeZoneInfo.CreateCustomTimeZone("Central Standard Time",
               tzi.BaseUtcOffset, "(GMT-06:00) Central Time (US & Canada)", 
               "Central Standard Time");

and I used that instance in the service call. I'm guessing I only needed to get the ID right (I set the offset, long name, etc as well).

Upvotes: 5

Related Questions