[This is preliminary documentation and is subject to change.]
Examples
iCalendar iCal = iCalendar.LoadFromUri(new Uri("http://somesite.com/calendar.ics"));
Assembly: DDay.iCal (in DDay.iCal.dll) Version: 0.71.0.0 (0.71.0.0)
Syntax
| C# |
|---|
public class iCalendar : ComponentBase, IDisposable |
Remarks
The following is an example of loading an iCalendar and displaying a text-based calendar.
CopyC#//
// The following code loads and displays an iCalendar
// with US Holidays for 2006.
//
iCalendar iCal = iCalendar.LoadFromUri(new Uri("http://www.applegatehomecare.com/Calendars/USHolidays.ics"));
List<Occurrence> occurrences = iCal.GetOccurrences(
new iCalDateTime(2006, 1, 1, "US-Eastern", iCal),
new iCalDateTime(2006, 12, 31, "US-Eastern", iCal));
foreach (Occurrence o in occurrences)
{
Event evt = o.Component as Event;
if (evt != null)
{
// Display the date of the event
Console.Write(o.Period.StartTime.Local.Date.ToString("MM/dd/yyyy") + " -\t");
// Display the event summary
Console.Write(evt.Summary);
// Display the time the event happens (unless it's an all-day event)
if (evt.Start.HasTime)
{
Console.Write(" (" + evt.Start.Local.ToShortTimeString() + " - " + evt.End.Local.ToShortTimeString());
if (evt.Start.TimeZoneInfo != null)
Console.Write(" " + evt.Start.TimeZoneInfo.TimeZoneName);
Console.Write(")");
}
Console.Write(Environment.NewLine);
}
}
The following example loads all active to-do items from an iCalendar:
CopyC#//
// The following code loads and displays active todo items from an iCalendar
// for January 6th, 2006.
//
iCalendar iCal = iCalendar.LoadFromUri(new Uri("http://somesite.com/calendar.ics"));
iCalDateTime dt = new iCalDateTime(2006, 1, 6, "US-Eastern", iCal);
foreach(Todo todo in iCal.Todos)
{
if (todo.IsActive(dt))
{
// Display the todo summary
Console.WriteLine(todo.Summary);
}
}
Inheritance Hierarchy
DDay.iCal.Components..::.iCalObject
DDay.iCal.Components..::.ComponentBase
DDay.iCal..::.iCalendar