+1 vote

I would like to send calendar events using UTC for the start and end times. This is the ics code that is being generated:

DTSTAMP:20160511T200257Z
DTSTART:20160513T170000
DTEND:20160513T180000

Notice the DTSTAMP includes the Z at the end to indicate UTC, but it is missing from DTSTART and DTEND. I believe this is causing a problem with some recipients. They are showing the time as local rather than converting from UTC. How can I make it include the Z?

by

1 Answer

0 votes
 
Best answer

As long as you are using DateTimeKind.Utc, 'Z' is there:

Appointment appointment = new Appointment();
Event newEvent = appointment.AddEvent();
newEvent.UID = "123";
newEvent.Stamp = new DateTime(2000, 12, 31, 23, 0, 0, DateTimeKind.Utc);
newEvent.Start = new DateTime(2000, 12, 31, 23, 0, 0, DateTimeKind.Utc);
newEvent.End = new DateTime(2000, 12, 31, 23, 59, 59, DateTimeKind.Utc);

Assert.AreEqual(
@"BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:-//Limilabs//Mail.dll//EN
BEGIN:VEVENT
UID:123
CLASS:PUBLIC
STATUS:CONFIRMED
DTSTAMP:20001231T230000Z
DTSTART:20001231T230000Z
DTEND:20001231T235959Z
END:VEVENT
END:VCALENDAR
",
appointment.RenderFinal());
by (297k points)
...