您好,我正在从DDay.ical迁移到Ical.Net nuget pacakages,但是我被以下在DDay.Ical日历中添加时区的代码卡住了,请帮助
前面的代码:
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));迁移到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);这里我知道calendar.AddTimezone会考ITimezone,但是我不知道怎么通过,请帮帮忙。
发布于 2016-08-25 22:19:50
VTimeZone是ITimeZone接口的具体实现。ical.net示例将如下所示:
var calendar = new Ical.Net.Calendar();
// ical.net supports BCL time zones as well as IANA time zones
calendar.AddTimeZone(new VTimeZone(objResponse.UserTimezone));将来,如果时区字符串与任何已知字符串不匹配,我可能会更改VTimeZone构造函数以抛出异常。然而,现在,它是相当愚蠢的。在幕后,如果所有其他方法都失败了,ical.net将默认使用代码运行所在的系统时区。这可能不太好。
我还添加了一个根据您的问题改编的wiki页面:
https://github.com/rianjs/ical.net/wiki/Working-with-time-zones
https://stackoverflow.com/questions/39147095
复制相似问题