Exchange/Outlook integration, Time Zones and conversions

Generic code to create all tasks at 0000 at the app server time zone
Wherever the app is installed, it will use that Time Zone – IST, EST etc

private static void setMeetingTimeZone(CalendarItemType result)
{
// from http://msdn.microsoft.com/en-us/library/bb738399.aspx
result.MeetingTimeZone = new TimeZoneType();
result.MeetingTimeZone.TimeZoneName = TimeZoneInfo.Local.StandardName;
}

private void saveOccurences(int recurringMasterTaskId, List occurences)
{
foreach (CalendarItemType occurence in occurences)
{
TaskDALC.InsertTaskOccurence(recurringMasterTaskId,
TimeZoneInfo.ConvertTimeFromUtc(occurence.Start, TimeZoneInfo.Local),
TimeZoneInfo.ConvertTimeFromUtc(occurence.End, TimeZoneInfo.Local),
occurence.ItemId.Id, occurence.ItemId.ChangeKey,
"", "");
}
}

Outlook client could be anywhere and can send a date not in sync with Exchange.
So instead of Item.Start we send the date as Item.StartUTC in the script (plus there was a client culture related fix too).

Month(Item.StartUTC) & "/" & Day(Item.StartUTC) & "/" & Year(Item.StartUTC) & " " & Hour(Item.StartUTC) & "_" & Minute(Item.StartUTC) & "|" & _

Then before updating the DB, we convert the UTC time to server time
TimeZoneInfo.ConvertTimeFromUtc(DateTime.Parse(values[1]), TimeZoneInfo.Local).Date;

-

Whether we would be considering DST changes in our conversions.
The methods we are using are

In Outlook
http://msdn.microsoft.com/en-us/library/bb176887.aspx (AppointmentItem.StartUTC Property)
In .Net
http://msdn.microsoft.com/en-us/library/system.timezoneinfo.converttimefromutc.aspx

I am sure about the 2nd one but not about the first.
The DST changes, especially for US, are exceedingly complex (floating dates, different for dates before 2007 etc).

I made a recurring task on outlook though and Outlook correctly adjusts the time zone for DST on different months.
So I’m guessing the script should work ok too but if you want, you could raise it as a concern.

Comments

Archive

Show more