In the below code:-
context.Response.Write("DTSTART:" + startDate.ToUniversalTime().ToString("yyyyMMddTHHmmssZ") + Environment.NewLine);
context.Response.Write("DTEND:" + GetMeetingEndDate(startDate, endDate).ToString("yyyyMMddTHHmmssZ") + Environment.NewLine);
the DTSTART
is set to value startDate.ToUniversalTime()
whereas in function GetMeetingEndDate
the dates are passed without converting into UTC
. Because of this startdate
is always correct but iCal is treating your local enddate
as UTC date. That might be causing the problem of adding extra hour. The solution is to change the below code block as
context.Response.Write("DTEND:" + GetMeetingEndDate(startDate.ToUniversalTime(), endDate.ToUniversalTime()).ToString("yyyyMMddTHHmmssZ") + Environment.NewLine);