-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TimeZone details not being honoured in Outlook #540
Comments
I am new to this library and using it to create ICS files via a webservice. I have noticed a similar issue with timezones. (In this example, US Mountain Time, Start time = 11 am, End time 1:30 pm) When I create the ICS, I add the timezone : ...
var calendar = new Calendar();
string tz = TZConvert.WindowsToIana(EventNode.EventTimezone.Id);
calendar.AddTimeZone(new VTimeZone(tz));
... And I see it added to the resulting ICS file:
But when I open the file on my own computer (In USA Eastern Time zone), the timezone displayed is Eastern - BUT, the times haven't been converted properly (it is still showing 11:00 AM - 1:30 PM, when it SHOULD show 1:00 PM - 3:30 PM for the Eastern timezone) I would expect it to EITHER show the original times in the original timezone (Mountain) OR show the adjusted times in the Eastern timezone... When I manually change the timezone in Outlook to Mountain time, and save the event - it appears on my calendar in the proper slot for Eastern time: If I then Save the even as an ICS file and compare it to the generated one, these are the differences: The main difference seems to be that Outlook is using Windows-style timezones rather than IANA. Additionally, there is all that Daylight saving stuff/offsets, etc. (as already discussed in #58). A bit more searching on the Issues here turned up this other post: #487, which suggests that a change to the generating code would perhaps fix it, so I updated my code to: ...
var calendar = new Calendar();
string tz = TZConvert.WindowsToIana(EventNode.EventTimezone.Id);
calendar.AddTimeZone(VTimeZone.FromDateTimeZone(tz));
... This did result in a lot more timezone data being added to the generated file:
But Outlook treated it the same - as if it were in Eastern Time. 😢 I notice that the DTSTART values are different... Additionally, in the VEVENT data there are some differences: Outlook adds its time zone name to the DTSTART and DTEND values... (Additionally, I notice that Outlook names the timezone as "Mountain Standard Time", but this event is actually occurring in "Mountain Daylight Time" - but this seems to match up with the way C# TimeZoneInfo objects are identified, so it might not be relevant.) I decided to try a different tactic - not specifying any timezone info, and changing the provide start and end dates to UTC equivalent times... But Outlook STILL treated it as Eastern Time - just totally off, since it was using the UTC time values... I also tried explicitly specifying UTC... ...
var calendar = new Calendar();
var tz = "Etc/UTC";
calendar.AddTimeZone(VTimeZone.FromDateTimeZone(tz));
... But that made no difference either. I am kind of stuck now. If anyone has other suggestions, I'd appreciate them. |
After spending more time googling and testing, I've had a breakthrough today! According to this post, a "Z" at the end of the DTSTART/DTEND time values indicates UTC time. I did another UTC test to see if the generated file had the "Z" appended. It did not. I looked closer at how I was generating the start/end dates for the event, and realized there were additional overloads for "CalDateTime()" which included tzid as a parameter. I updated the code I was using to create the start/end dates like this:
when I re-ran the generation, the resulting file now had some more information:
The date values didn't include the trailing "Z", BUT opening the file in Outlook properly adjusted the time to 1:00 PM - 3:30 PM for the Eastern timezone: 👏🏻🎉 As a final test, I went back to using the specified timezone: string tz = TZConvert.WindowsToIana(EventNode.EventTimezone.Id);
calendar.AddTimeZone(VTimeZone.FromDateTimeZone(tz));
...
Start= new CalDateTime(DateTimeValue, tz);
End= new CalDateTime(DateTimeValue, tz);
... The resulting file included the timezone info on the DTSTART & DTEND values:
@StevenReid - I think this is what you were looking for? When I opened the ICS in Outlook, it did NOT show "Mountain Time" as the timezone - but, like for the UTC, It DID adjust the time to 1:00 PM - 3:30 PM for the Eastern timezone. I do wish MS Outlook would better follow the standard, but this works for my purposes. |
Very helpful @hfloyd, thank you very much. |
@afortaleza I'm glad to document these things, so someone else can save several hours of trouble 😊 |
I have recently received an ICS file containing multiple events that was created using this product.
The events were created for "Eastern Standard Time" and I am in "AUS Eastern Standard Time"
When opening the Time Zone details for the event were not honoured.
The ICS file had TZID information.
When i added the TZID information to each DTSTART and DTEND entry, the correct timezone was added to each event.
The text was updated successfully, but these errors were encountered: