开发者

DDay iCal w/ Non-DST Time Zones

I've posted to the forums for the DDay iCal library but thought to post it here in case any users have come across this situation. From my forum post:

I've come across what appears to be a bug in how the time zone section is generated in an iCal file- adding a time zone that does not support Daylight Saving Time creates an empty VTIMEZONE section, which breaks the iCal. A quick glance at the code leads me to believe that the section is generated by the collection returned by TimeZoneInfo.GetAdjustmentRules(), which is empty for time zones that do not observe DST.

The code at the bottom of the post should demonstrate this issue.

If this is not a bug (and I am not convinced that it is!), I'd very much appreciate guidance in getting these to work.

void Main()
{
    foreach (var tz in TimeZoneInfo.GetSystemTimeZones())
    {
        var cal = GetCal(tz);
        Console.WriteLine(tz.Id + " :: " + tz.SupportsDaylightSavingTime + " :: " + cal.TimeZones.First().ID);
    }
}

iCalendar GetCal(TimeZoneInfo timeZone)
{
    var calendar = new iCalendar();

    calendar.AddChild(iCalTimeZone.FromSystemTimeZone(timeZone));

    var @event = new Event
                     {
                         Name = "VEVENT",
                         DTStart = new iCalDateTime(DateTime.Now, timeZone.Id),
           开发者_如何学运维              DTEnd = new iCalDateTime(DateTime.Now + TimeSpan.FromHours(1))
                     };

    calendar.Events.Add(@event);

    return calendar;
}


I pulled down the latest source from SVN and the fix for this has already been applied; it's just not in the latest release DLL as of 6/30/2011.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜