I have some DDay iCal code that takes events from our SQL database and creates an iCal file so users can subscribe to the internet calendar in Outlook or Google Calendar. It's working fine except when a user in a different time zone syncs to their calendar it displays the time incorrectly. Our web server is in central time so a user in eastern time would see the time as 1 hour before the actual event time. Basically I want iCal to ignore time zones and just display the start and end time as it appears in my database. I have a feeling this is going to be impossible and we'll have to do the time conversion ourselves.
Dim iCal As iCalendar = New iCalendar()
Dim evt As [Event]
iCal.AddLocalTimeZone()
Dim dtStart As DateTime = dtr_SQL("StartDate").ToString()
Dim dtEnd As DateTime = dtr_SQL("EndDate").ToString()
Dim startDate As iCalDateTime = dtStart.ToUniversalTime()
Dim endDate As iCalDateTime = dtEnd.ToUniversalTime()
evt = iCal.Create(Of [Event])()
evt.Start = startDate
evt.Start.HasTime = True
evt.Start.IsUniversalTime = True
evt.End = endDate
evt.End.HasTime = True
evt.End.IsUniversalTime = True
Since you are getting the time from a SQL database, it is unlikely there is a timezone associated with the time you are pulling. You will likely need to assign the time you are pulling to "Central Standard Time" as shown here:
Dim centralTime As New Date(dtStart) 'using the datetime you pulled from your database
Dim centralZoneId As String = "Central Standard Time"
Dim centralZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(centralZoneId)
Dim UTCTime as Date = TimeZoneInfo.ConvertTimeToUtc(centralTime, centralZone)
Now, if a user in Eastern Standard Time is executing your code, the time will be read from the database as CST (not EST, which is likely where your problem is coming from) and then converted to UTC. With a clear timezone associated with these times, Outlook and Google should be able to handle the rest when your calendar appointments are read by users in different time zones.
I hope this helps!