我正在使用DDay.iCal创建iCal供稿。它有效,但我无法弄清楚如何设置Feed的时区。这是基本代码:
iCalendar iCal = new iCalendar();
// <-- Set the Timezone HERE to PST (Pacific Daylight Time)
Event evt = iCal.Create<Event>();
evt.Start = new iCalDateTime(meeting.MeetDate);
evt.End = evt.Start.AddHours(4); // 4 hour event
evt.Description = "This meeting...";
evt.Summary = "Event Summary";
有什么想法吗?
答案 0 :(得分:9)
在另一个答案中,作者没有提到示例6中这三行之上的行:
// First load a file containing time zone information for North & South America
IICalendar timeZones = iCalendar.LoadFromFile("America.ics")[0];
这样就行不通了。一个选项是:
iCalendar iCal = new iCalendar();
System.TimeZoneInfo timezoneinfo = System.TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
iCalTimeZone timezone = iCalTimeZone.FromSystemTimeZone(timezoneinfo);
iCal.AddTimeZone(timezone);
或者只需添加本地时区:
iCalendar iCal = new iCalendar();
iCal.AddLocalTimeZone();
要查找所有已注册的时区,请使用this snippet:
ReadOnlyCollection<TimeZoneInfo> zones = TimeZoneInfo.GetSystemTimeZones();
Console.WriteLine("The local system has the following {0} time zones", zones.Count);
foreach (TimeZoneInfo zone in zones.OrderBy(z => z.Id))
Console.WriteLine(zone.Id);
Console.ReadLine();
答案 1 :(得分:3)
下载中的示例6是设置时区和事件的诸如此类的东西。检查一下。
相关专栏:
IICalendar iCal = new iCalendar();
iCal.AddChild(timeZones.GetTimeZone("America/New_York"));
iCal.AddChild(timeZones.GetTimeZone("America/Denver"));
// Set the event to start at 11:00 A.M. New York time on January 2, 2007.
evt.Start = new iCalDateTime(2007, 1, 2, 11, 0, 0, "America/New_York", iCal)