Hi I am migrating from DDay.ical to Ical.Net nuget pacakages but I get stuck in the following code which add Timezone in DDay.Ical calendar please help
Previous code:
List<DOAppointment> lst = objResponse.Appointments;
string timeZoneName = objResponse.UserTimezone;
iCalendar calendar = new DDay.iCal.iCalendar();
var timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneName);
calendar.AddTimeZone(iCalTimeZone.FromSystemTimeZone(timeZone));
Migrating into Ical.Net:
List<DOAppointment> lst = objResponse.Appointments;
string timeZoneName = objResponse.UserTimezone;
Ical.Net.Calendar calendar = new Ical.Net.Calendar();
var timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneName);
ITimeZone tzID = timeZone;
calendar.AddTimeZone(tzID);
Here I know that calendar.AddTimezone will take ITimezone but how to pass it I am not getting please help.
VTimeZone
is the concrete implementation of theITimeZone
interface. The ical.net example would look like this:In the future, I may change the
VTimeZone
constructor to throw an exception if the time zone string doesn't match anything known. Right now, though, it's pretty dumb. Behind the scenes, ical.net will default to the system time zone that the code is running on, if all else fails. That's probably not good.I also added a wiki page with an adaptation of your question:
https://github.com/rianjs/ical.net/wiki/Working-with-time-zones