我正在使用DDay.iCal创建一个iCal提要。它可以工作,但我不知道如何设置提要的时区。下面是基本代码:
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";有什么想法吗?
发布于 2012-02-07 22:49:36
在另一个答案中,作者没有提到示例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();发布于 2010-09-24 23:43:20
下载中的Example6正在为事件设置时区之类的东西。看看这个。
相关行:
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)https://stackoverflow.com/questions/3774548
复制相似问题