Kel*_*tex 5 c# asp.net icalendar
我正在使用DDay.iCal创建一个iCal feed .它有效,但我无法弄清楚如何设置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";
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
在另一个答案中,作者没有提到示例6中这三行之上的行:
// First load a file containing time zone information for North & South America
IICalendar timeZones = iCalendar.LoadFromFile("America.ics")[0];
Run Code Online (Sandbox Code Playgroud)
这样就行不通了.一个选项是:
iCalendar iCal = new iCalendar();
System.TimeZoneInfo timezoneinfo = System.TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
iCalTimeZone timezone = iCalTimeZone.FromSystemTimeZone(timezoneinfo);
iCal.AddTimeZone(timezone);
Run Code Online (Sandbox Code Playgroud)
或者只是添加本地时区:
iCalendar iCal = new iCalendar();
iCal.AddLocalTimeZone();
Run Code Online (Sandbox Code Playgroud)
要查找所有已注册的时区,请使用以下代码段:
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();
Run Code Online (Sandbox Code Playgroud)
下载中的示例 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)
Run Code Online (Sandbox Code Playgroud)