本文介绍了如何设置时区使用DDay.iCal的iCal供稿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建使用的iCal供稿。它的工作原理,但我想不出如何设置为饲料的时区。这里是基本的code:

I'm creating an iCal feed using DDay.iCal. It works, but I can't figure out how to set the timezone for the feed. Here's the basic code:

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";

任何想法?

推荐答案

在对方的回答是,作者没有提那些三行这就是例子6在上面的一行:

In the other answer, the author fails to mention the line above those three lines that's in example 6:

// First load a file containing time zone information for North & South America
IICalendar timeZones = iCalendar.LoadFromFile("America.ics")[0];

所以这是行不通的。一个选择是:

So that won't work. An option would be:

iCalendar iCal = new iCalendar();

System.TimeZoneInfo timezoneinfo = System.TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
iCalTimeZone timezone = iCalTimeZone.FromSystemTimeZone(timezoneinfo);
iCal.AddTimeZone(timezone);

或者干脆添加本地时区:

Or simply add the local timezone:

iCalendar iCal = new iCalendar();
iCal.AddLocalTimeZone();

要查找所有已注册的时区,使用:

To find all registered timezones, use 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();

这篇关于如何设置时区使用DDay.iCal的iCal供稿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 10:20